Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose plex UDP ports in loadbalancer #105

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions charts/kube-plex/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
{{- range .Values.ingress.hosts }}
http://{{ . }}
{{- 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 {{ template "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 svc -w {{ template "fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.service.externalPort }}
{{- else if contains "ClusterIP" .Values.service.type }}
echo http://$SERVICE_IP:{{ .Values.serviceTCP.externalPort }}
{{- else if contains "ClusterIP" .Values.serviceTCP.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl port-forward $POD_NAME 8080:{{ .Values.service.externalPort }}
kubectl port-forward $POD_NAME 8080:{{ .Values.serviceTCP.externalPort }}
{{- end }}
21 changes: 21 additions & 0 deletions charts/kube-plex/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,32 @@ spec:
timeoutSeconds: 10
ports:
- name: pms
protocol: TCP
containerPort: 32400
- name: http
protocol: TCP
containerPort: 32400
- name: https
protocol: TCP
containerPort: 32443
- 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 }}"
Expand Down
61 changes: 61 additions & 0 deletions charts/kube-plex/templates/service-tcp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "fullname" . }}-tcp
labels:
app: {{ template "name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- 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: https
- name: plex-dlna
port: 1900
targetPort: plex-dlna
selector:
app: {{ template "name" . }}
release: {{ .Release.Name }}
65 changes: 65 additions & 0 deletions charts/kube-plex/templates/service-udp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "fullname" . }}-udp
labels:
app: {{ template "name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- 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:
app: {{ template "name" . }}
release: {{ .Release.Name }}
59 changes: 0 additions & 59 deletions charts/kube-plex/templates/service.yaml

This file was deleted.

30 changes: 26 additions & 4 deletions charts/kube-plex/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ claimToken: ""
# Set the timezone of the plex server
timezone: Europe/London

service:
serviceTCP:
type: ClusterIP
port: 32400
## Specify the nodePort value for the LoadBalancer and NodePort service types.
Expand All @@ -30,7 +30,8 @@ service:
## set the LoadBalancer service type to internal only.
## ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer
##
annotations: {}
annotations:
metallb.universe.tf/allow-shared-ip: plex-svc
labels: {}
## Use loadBalancerIP to request a specific static IP,
## otherwise leave blank
Expand All @@ -40,6 +41,27 @@ service:
## Set the externalTrafficPolicy in the Service to either Cluster or Local
# externalTrafficPolicy: Cluster

serviceUDP:

## Specify the nodePort value for the LoadBalancer and NodePort service types.
## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport
##
# nodePort:
## 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
##
loadBalancerIP:
# loadBalancerSourceRanges: []
## Set the externalTrafficPolicy in the Service to either Cluster or Local
# externalTrafficPolicy: Cluster

ingress:
enabled: false
# Used to create an Ingress record.
Expand Down Expand Up @@ -96,7 +118,7 @@ persistence:
accessMode: ReadWriteMany
extraData: []
# Optionally specifify additional Data mounts. These will be mounted as
# /data-${name}. This should be in the same format as the above 'data',
# /data-${name}. This should be in the same format as the above 'data',
# with the additional field 'name'
# - claimName: "special-tv"
# name: 'foo'
Expand Down Expand Up @@ -133,7 +155,7 @@ podAnnotations: {}

deploymentAnnotations: {}

proxy:
proxy:
# This allows to set a proxy environment variable, which PMS uses to fetch the token and assets like movie cover
enable: false
# http: "http://proxy:8080"
Expand Down