From b71d3e7581f9d8c6fc6dc38a2620ca2d7dff0aa5 Mon Sep 17 00:00:00 2001 From: Devin Buhl Date: Mon, 6 Jul 2020 15:58:44 -0400 Subject: [PATCH] [plex] add UDP to plex (#266) * add UDP to plex * fix up udp type * comment out metallb annotations * remove pesky ports --- charts/plex/Chart.yaml | 2 +- charts/plex/templates/NOTES.txt | 8 ++-- charts/plex/templates/deployment.yaml | 19 ++++++++ charts/plex/templates/service-tcp.yaml | 57 ++++++++++++++++++++++++ charts/plex/templates/service-udp.yaml | 61 ++++++++++++++++++++++++++ charts/plex/templates/service.yaml | 54 ----------------------- charts/plex/values.yaml | 20 ++++++++- 7 files changed, 161 insertions(+), 60 deletions(-) create mode 100644 charts/plex/templates/service-tcp.yaml create mode 100644 charts/plex/templates/service-udp.yaml delete mode 100644 charts/plex/templates/service.yaml diff --git a/charts/plex/Chart.yaml b/charts/plex/Chart.yaml index b358e7c2..3e19ff58 100644 --- a/charts/plex/Chart.yaml +++ b/charts/plex/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 appVersion: 1.19.1.2645-ccb6eb67e description: Plex Media Server name: plex -version: 1.4.0 +version: 1.5.0 keywords: - plex home: https://plex.tv/ diff --git a/charts/plex/templates/NOTES.txt b/charts/plex/templates/NOTES.txt index c48a248a..a4119425 100644 --- a/charts/plex/templates/NOTES.txt +++ b/charts/plex/templates/NOTES.txt @@ -3,16 +3,16 @@ {{- range $host := .Values.ingress.hosts }} http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }} {{- end }} -{{- else if contains "NodePort" .Values.service.type }} +{{- else if contains "NodePort" .Values.serviceTCP.type }} export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "plex.fullname" . }}) export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} +{{- else if contains "LoadBalancer" .Values.serviceTCP.type }} NOTE: It may take a few minutes for the LoadBalancer IP to be available. You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "plex.fullname" . }}' export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "plex.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} + echo http://$SERVICE_IP:{{ .Values.serviceTCP.port }} +{{- else if contains "ClusterIP" .Values.serviceTCP.type }} export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "plex.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") echo "Visit http://127.0.0.1:8080 to use your application" kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 diff --git a/charts/plex/templates/deployment.yaml b/charts/plex/templates/deployment.yaml index e17994cf..233120f0 100644 --- a/charts/plex/templates/deployment.yaml +++ b/charts/plex/templates/deployment.yaml @@ -69,7 +69,26 @@ spec: imagePullPolicy: {{ .Values.image.pullPolicy }} ports: - name: pms + protocol: TCP containerPort: 32400 + - name: plex-dlna + protocol: TCP + containerPort: 32469 + - name: plex-dlna-udp + protocol: UDP + containerPort: 1900 + - name: plex-gdm1 + protocol: UDP + containerPort: 32410 + - name: plex-gdm2 + protocol: UDP + containerPort: 32412 + - name: plex-gdm3 + protocol: UDP + containerPort: 32413 + - name: plex-gdm4 + protocol: UDP + containerPort: 32414 env: - name: TZ value: "{{ .Values.timezone }}" diff --git a/charts/plex/templates/service-tcp.yaml b/charts/plex/templates/service-tcp.yaml new file mode 100644 index 00000000..f8e1be4b --- /dev/null +++ b/charts/plex/templates/service-tcp.yaml @@ -0,0 +1,57 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "plex.fullname" . }}-tcp + labels: + {{- include "plex.labels" . | nindent 4 }} +{{- if .Values.serviceTCP.labels }} +{{ toYaml .Values.serviceTCP.labels | indent 4 }} +{{- end }} +{{- with .Values.serviceTCP.annotations }} + annotations: +{{ toYaml . | indent 4 }} +{{- end }} +spec: +{{- if (or (eq .Values.serviceTCP.type "ClusterIP") (empty .Values.serviceTCP.type)) }} + type: ClusterIP + {{- if .Values.serviceTCP.clusterIP }} + clusterIP: {{ .Values.serviceTCP.clusterIP }} + {{end}} +{{- else if eq .Values.serviceTCP.type "LoadBalancer" }} + type: {{ .Values.serviceTCP.type }} + {{- if .Values.serviceTCP.loadBalancerIP }} + loadBalancerIP: {{ .Values.serviceTCP.loadBalancerIP }} + {{- end }} + {{- if .Values.serviceTCP.loadBalancerSourceRanges }} + loadBalancerSourceRanges: +{{ toYaml .Values.serviceTCP.loadBalancerSourceRanges | indent 4 }} + {{- end -}} +{{- else }} + type: {{ .Values.serviceTCP.type }} +{{- end }} +{{- if .Values.serviceTCP.externalIPs }} + externalIPs: +{{ toYaml .Values.serviceTCP.externalIPs | indent 4 }} +{{- end }} + {{- if .Values.serviceTCP.externalTrafficPolicy }} + externalTrafficPolicy: {{ .Values.serviceTCP.externalTrafficPolicy }} + {{- end }} + ports: + - name: pms + port: {{ .Values.serviceTCP.port }} + protocol: TCP + targetPort: pms +{{ if (and (eq .Values.serviceTCP.type "NodePort") (not (empty .Values.serviceTCP.nodePort))) }} + nodePort: {{.Values.serviceTCP.nodePort}} +{{ end }} + - name: http + port: 80 + targetPort: pms + - name: https + port: 443 + targetPort: pms + - name: plex-dlna + port: 1900 + targetPort: plex-dlna + selector: + {{- include "plex.selectorLabels" . | nindent 4 }} diff --git a/charts/plex/templates/service-udp.yaml b/charts/plex/templates/service-udp.yaml new file mode 100644 index 00000000..c4f07ab9 --- /dev/null +++ b/charts/plex/templates/service-udp.yaml @@ -0,0 +1,61 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "plex.fullname" . }}-udp + labels: + {{- include "plex.labels" . | nindent 4 }} +{{- if .Values.serviceUDP.labels }} +{{ toYaml .Values.serviceUDP.labels | indent 4 }} +{{- end }} +{{- with .Values.serviceUDP.annotations }} + annotations: +{{ toYaml . | indent 4 }} +{{- end }} +spec: +{{- if (or (eq .Values.serviceUDP.type "ClusterIP") (empty .Values.serviceUDP.type)) }} + type: ClusterIP + {{- if .Values.serviceUDP.clusterIP }} + clusterIP: {{ .Values.serviceUDP.clusterIP }} + {{end}} +{{- else if eq .Values.serviceUDP.type "LoadBalancer" }} + type: {{ .Values.serviceUDP.type }} + {{- if .Values.serviceUDP.loadBalancerIP }} + loadBalancerIP: {{ .Values.serviceUDP.loadBalancerIP }} + {{- end }} + {{- if .Values.serviceUDP.loadBalancerSourceRanges }} + loadBalancerSourceRanges: +{{ toYaml .Values.serviceUDP.loadBalancerSourceRanges | indent 4 }} + {{- end -}} +{{- else }} + type: {{ .Values.serviceUDP.type }} +{{- end }} +{{- if .Values.serviceUDP.externalIPs }} + externalIPs: +{{ toYaml .Values.serviceUDP.externalIPs | indent 4 }} +{{- end }} + {{- if .Values.serviceUDP.externalTrafficPolicy }} + externalTrafficPolicy: {{ .Values.serviceUDP.externalTrafficPolicy }} + {{- end }} + ports: + - name: plex-dlna-udp + port: 1900 + protocol: UDP + targetPort: plex-dlna-udp + - name: plex-gdm1 + port: 32410 + protocol: UDP + targetPort: plex-gdm1 + - name: plex-gdm2 + port: 32412 + protocol: UDP + targetPort: plex-gdm2 + - name: plex-gdm3 + port: 32413 + protocol: UDP + targetPort: plex-gdm3 + - name: plex-gdm4 + port: 32414 + protocol: UDP + targetPort: plex-gdm4 + selector: + {{- include "plex.selectorLabels" . | nindent 4 }} diff --git a/charts/plex/templates/service.yaml b/charts/plex/templates/service.yaml deleted file mode 100644 index a0cc6c3a..00000000 --- a/charts/plex/templates/service.yaml +++ /dev/null @@ -1,54 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ include "plex.fullname" . }} - labels: - {{- include "plex.labels" . | nindent 4 }} -{{- if .Values.service.labels }} -{{ toYaml .Values.service.labels | indent 4 }} -{{- end }} -{{- with .Values.service.annotations }} - annotations: -{{ toYaml . | indent 4 }} -{{- end }} -spec: -{{- if (or (eq .Values.service.type "ClusterIP") (empty .Values.service.type)) }} - type: ClusterIP - {{- if .Values.service.clusterIP }} - clusterIP: {{ .Values.service.clusterIP }} - {{end}} -{{- else if eq .Values.service.type "LoadBalancer" }} - type: {{ .Values.service.type }} - {{- if .Values.service.loadBalancerIP }} - loadBalancerIP: {{ .Values.service.loadBalancerIP }} - {{- end }} - {{- if .Values.service.loadBalancerSourceRanges }} - loadBalancerSourceRanges: -{{ toYaml .Values.service.loadBalancerSourceRanges | indent 4 }} - {{- end -}} -{{- else }} - type: {{ .Values.service.type }} -{{- end }} -{{- if .Values.service.externalIPs }} - externalIPs: -{{ toYaml .Values.service.externalIPs | indent 4 }} -{{- end }} - {{- if .Values.service.externalTrafficPolicy }} - externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy }} - {{- end }} - ports: - - name: pms - port: {{ .Values.service.port }} - protocol: TCP - targetPort: pms -{{ if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePort))) }} - nodePort: {{.Values.service.nodePort}} -{{ end }} - - name: http - port: 80 - targetPort: pms - - name: https - port: 443 - targetPort: pms - selector: - {{- include "plex.selectorLabels" . | nindent 4 }} diff --git a/charts/plex/values.yaml b/charts/plex/values.yaml index da3ea606..77bd569d 100644 --- a/charts/plex/values.yaml +++ b/charts/plex/values.yaml @@ -67,7 +67,7 @@ securityContext: {} # runAsNonRoot: true # runAsUser: 1000 -service: +serviceTCP: type: ClusterIP port: 32400 ## Specify the nodePort value for the LoadBalancer and NodePort service types. @@ -79,6 +79,24 @@ service: ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer ## annotations: {} + # metallb.universe.tf/allow-shared-ip: plex-svc + labels: {} + ## Use loadBalancerIP to request a specific static IP, + ## otherwise leave blank + ## + loadBalancerIP: + # loadBalancerSourceRanges: [] + ## Set the externalTrafficPolicy in the Service to either Cluster or Local + # externalTrafficPolicy: Cluster + +serviceUDP: + type: ClusterIP + ## Provide any additional annotations which may be required. This can be used to + ## set the LoadBalancer service type to internal only. + ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer + ## + annotations: {} + # metallb.universe.tf/allow-shared-ip: plex-svc labels: {} ## Use loadBalancerIP to request a specific static IP, ## otherwise leave blank