[plex] add UDP to plex (#266)

* add UDP to plex

* fix up udp type

* comment out metallb annotations

* remove pesky ports
This commit is contained in:
Devin Buhl 2020-07-06 15:58:44 -04:00 committed by GitHub
parent 2780dae688
commit b71d3e7581
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 161 additions and 60 deletions

View File

@ -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/

View File

@ -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

View File

@ -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 }}"

View File

@ -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 }}

View File

@ -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 }}

View File

@ -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 }}

View File

@ -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