Skip to content

Commit

Permalink
Merge pull request #53 from UnstoppableMango/advertise-ip
Browse files Browse the repository at this point in the history
Fix ADVERTISE_IP to work with structured ingress paths
  • Loading branch information
ressu authored Jan 19, 2024
2 parents 561cbec + e309894 commit f6d611c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
29 changes: 29 additions & 0 deletions charts/kube-plex/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
15 changes: 2 additions & 13 deletions charts/kube-plex/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f6d611c

Please sign in to comment.