diff --git a/charts/kube-plex/templates/_helpers.tpl b/charts/kube-plex/templates/_helpers.tpl index f0d83d2..ff337ce 100644 --- a/charts/kube-plex/templates/_helpers.tpl +++ b/charts/kube-plex/templates/_helpers.tpl @@ -14,3 +14,32 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this {{- $name := default .Chart.Name .Values.nameOverride -}} {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} {{- end -}} + +{{/* +Create a list of values for ADVERTISE_IP +*/}} +{{- define "advertiseIp" -}} +{{- $hosts := list -}} +{{- if (or (eq .Values.service.type "ClusterIP") (eq .Values.service.type "LoadBalancer") (empty .Values.service.type)) -}} + {{- if .Values.service.loadBalancerIP -}}{{- $hosts = printf "https://%s:32400" .Values.service.loadBalancerIP | append $hosts -}}{{- end -}} + {{- if index .Values.service.annotations "dns.pfsense.org/hostname" -}} + {{- range splitList "," (index .Values.service.annotations "dns.pfsense.org/hostname") -}} + {{- $hosts = printf "https://%s:32400" . | append $hosts -}} + {{- end -}} + {{- end -}} + {{- range .Values.ingress.hosts -}} + {{- if kindIs "string" . }} + {{- if not (eq (lower .) "chart-example.local") -}} + {{- $hosts = printf "https://%s" . | append $hosts -}} + {{- $hosts = printf "https://%s:443" . | append $hosts -}} + {{- end -}} + {{- else }} + {{- if not (eq (lower .host) "chart-example.local") -}} + {{- $hosts = printf "https://%s" .host | append $hosts -}} + {{- $hosts = printf "https://%s:443" .host | append $hosts -}} + {{- end -}} + {{- end }} + {{- end -}} +{{- end -}} +{{ join "," $hosts }} +{{- end -}} diff --git a/charts/kube-plex/templates/deployment.yaml b/charts/kube-plex/templates/deployment.yaml index 0c967ca..71dc029 100644 --- a/charts/kube-plex/templates/deployment.yaml +++ b/charts/kube-plex/templates/deployment.yaml @@ -137,21 +137,10 @@ spec: {{- with .Values.extraEnv }} {{- get (fromYaml (include "env_vars" $)) "env" | toYaml | nindent 8 -}} {{- end }} +{{- if not (empty (include "advertiseIp" .)) }} # Fill ADVERTISE_IP section in plex automatically -{{- if (or (eq .Values.service.type "ClusterIP") (empty .Values.service.type)) }} - name: ADVERTISE_IP - value: | - {{ if .Values.ingress.hosts }}https://{{ join ",https://" .Values.ingress.hosts }}{{ end }} - {{ if .Values.ingress.hosts }},https://{{ join ",https://" .Values.ingress.hosts }}:443{{ end }} -{{- else if eq .Values.service.type "LoadBalancer" }} - {{- if (or .Values.service.loadBalancerIP .Values.ingress.hosts (index .Values.service.annotations "dns.pfsense.org/hostname")) }} - - name: ADVERTISE_IP - value: | - {{ if .Values.service.loadBalancerIP }}https://{{ .Values.service.loadBalancerIP }}:32400{{ end }} - {{ if index .Values.service.annotations "dns.pfsense.org/hostname" }},https://{{ join ",https://" (splitList "," (index .Values.service.annotations "dns.pfsense.org/hostname")) }}:32400{{ end }} - {{ if .Values.ingress.hosts }},https://{{ join ",https://" .Values.ingress.hosts }}{{ end }} - {{ if .Values.ingress.hosts }},https://{{ join ",https://" .Values.ingress.hosts }}:443{{ end }} - {{- end }} + value: {{ include "advertiseIp" . }} {{- end }} volumeMounts: - name: data