From 030fcbb41ec86382cde62654fe46a188787d01f5 Mon Sep 17 00:00:00 2001 From: Kjeld Schouten-Lebbing Date: Sat, 29 Apr 2023 08:43:02 +0200 Subject: [PATCH] fix(plex): use https for servicetype (#8270) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Description** ⚒️ Fixes #8182 ⚒️ Fixes #8150 **⚙️ Type of change** - [ ] ⚙️ Feature/App addition - [x] 🪛 Bugfix - [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] 🔃 Refactor of current code **🧪 How Has This Been Tested?** **📃 Notes:** **✔️ Checklist:** - [ ] ⚖️ My code follows the style guidelines of this project - [ ] 👀 I have performed a self-review of my own code - [ ] #️⃣ I have commented my code, particularly in hard-to-understand areas - [ ] 📄 I have made corresponding changes to the documentation - [ ] ⚠️ My changes generate no new warnings - [ ] 🧪 I have added tests to this description that prove my fix is effective or that my feature works - [ ] ⬆️ I increased versions for any altered app according to semantic versioning **➕ App addition** If this PR is an app addition please make sure you have done the following. - [ ] 🪞 I have opened a PR on [truecharts/containers](https://github.com/truecharts/containers) adding the container to TrueCharts mirror repo. - [ ] 🖼️ I have added an icon in the Chart's root directory called `icon.png` --- _Please don't blindly check all the boxes. Read them and only check those that apply. Those checkboxes are there for the reviewer to see what is this all about and the status of this PR with a quick glance._ --------- Signed-off-by: Kjeld Schouten-Lebbing Signed-off-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Co-authored-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com> --- charts/stable/plex/ci/basic-values.yaml | 0 charts/stable/plex/ci/https-values.yaml | 2 + charts/stable/plex/questions.yaml | 14 ++-- charts/stable/plex/templates/common.yaml | 77 +++++++++++-------- charts/stable/plex/values.yaml | 26 ++++++- .../security/securityContextContainer.yaml | 2 +- 6 files changed, 75 insertions(+), 46 deletions(-) create mode 100644 charts/stable/plex/ci/basic-values.yaml create mode 100644 charts/stable/plex/ci/https-values.yaml diff --git a/charts/stable/plex/ci/basic-values.yaml b/charts/stable/plex/ci/basic-values.yaml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/charts/stable/plex/ci/https-values.yaml b/charts/stable/plex/ci/https-values.yaml new file mode 100644 index 00000000000..de386234206 --- /dev/null +++ b/charts/stable/plex/ci/https-values.yaml @@ -0,0 +1,2 @@ +plex: + requireHTTPS: true diff --git a/charts/stable/plex/questions.yaml b/charts/stable/plex/questions.yaml index f64f1ebc3f7..411b55bcf1f 100644 --- a/charts/stable/plex/questions.yaml +++ b/charts/stable/plex/questions.yaml @@ -7,11 +7,9 @@ questions: # Include{global} # Include{workload} # Include{workloadDeployment} - # Include{replicas1} # Include{podSpec} # Include{containerMain} - - variable: env group: App Configuration label: Image Environment @@ -31,11 +29,8 @@ questions: schema: type: string default: "" - # Include{containerBasic} # Include{containerAdvanced} - - - variable: plex group: App Configuration label: Plex Configuration @@ -64,8 +59,15 @@ questions: schema: type: boolean default: true + - variable: requireHTTPS + label: Require HTTPS + description: Please use this toggle to "Require HTTPS", do not use the Plex UI. + schema: + type: boolean + default: true # Include{containerConfig} +# Include{podOptions} # Include{serviceRoot} # Include{serviceMain} # Include{serviceSelectorLoadBalancer} @@ -109,7 +111,6 @@ questions: # Include{ingressTraefik} # Include{ingressList} # Include{securityContextRoot} - - variable: runAsUser label: "runAsUser" description: "The UserID of the user running the application" @@ -131,7 +132,6 @@ questions: schema: type: int default: 568 - # Include{resources} # Include{advanced} # Include{addons} diff --git a/charts/stable/plex/templates/common.yaml b/charts/stable/plex/templates/common.yaml index 39feeab8ab5..821a261b085 100644 --- a/charts/stable/plex/templates/common.yaml +++ b/charts/stable/plex/templates/common.yaml @@ -1,43 +1,52 @@ {{/* Make sure all variables are set properly */}} -{{- include "tc.v1.common.loader.init" . }} +{{- include "tc.v1.common.loader.init" . -}} {{- $adv := list -}} -{{- $serverURL := "" }} -{{- if not (eq .Values.service.main.type "ClusterIP") }} - {{- $serverURL = (printf "%v://%v:%v" (.Values.service.main.ports.main.protocol | lower) .Values.plex.serverIP .Values.service.main.ports.main.port) }} -{{- end }} +{{- $serverURL := "" -}} +{{- $protocol := "http" -}} +{{- if .Values.plex.requireHTTPS -}} + {{- $protocol = "https" -}} +{{- end -}} -{{- $serverIngressURL := "" }} -{{- $host := "" }} -{{- if .Values.ingress.main.enabled }} - {{- with (first .Values.ingress.main.hosts) }} - {{- $host = .host }} - {{- $serverIngressURL = (printf "https://%v" .host) }} - {{- end }} -{{- end }} +{{- $_ := set .Values.workload.main.podSpec.containers.main.probes.liveness "protocol" $protocol -}} +{{- $_ := set .Values.workload.main.podSpec.containers.main.probes.readiness "protocol" $protocol -}} +{{- $_ := set .Values.workload.main.podSpec.containers.main.probes.startup "protocol" $protocol -}} -{{- $serverIngressURLPort := "" }} -{{- if $host }} - {{- if not (eq .Values.service.main.type "ClusterIP") }} - {{- $port := .Values.service.main.ports.main.port }} - {{- $serverIngressURLPort = printf "https://%v:%v" $host $port }} - {{- end }} -{{- end }} +{{- if not (eq .Values.service.main.type "ClusterIP") -}} + {{- $serverURL = (printf "%v://%v:%v" $protocol .Values.plex.serverIP .Values.service.main.ports.main.port) -}} +{{- end -}} -{{- with $serverURL }} - {{- $adv = append $adv . -}} -{{- end }} -{{- with $serverIngressURL }} - {{- $adv = append $adv . -}} -{{- end }} -{{- with $serverIngressURLPort }} - {{- $adv = append $adv . -}} -{{- end }} -{{- with .Values.plex.additionalAdvertiseURL }} - {{- $adv = append $adv . -}} -{{- end }} +{{- $serverIngressURL := "" -}} +{{- $host := "" -}} +{{- if .Values.ingress.main.enabled -}} + {{- with (first .Values.ingress.main.hosts) -}} + {{- $host = .host -}} + {{- $serverIngressURL = (printf "https://%v" .host) -}} + {{- end -}} +{{- end -}} -{{- $_ := set .Values.workload.main.podSpec.containers.main.env "ADVERTISE_IP" (join "," $adv) }} +{{- $serverIngressURLPort := "" -}} +{{- if $host -}} + {{- if not (eq .Values.service.main.type "ClusterIP") -}} + {{- $port := .Values.service.main.ports.main.port -}} + {{- $serverIngressURLPort = printf "https://%v:%v" $host $port -}} + {{- end -}} +{{- end -}} + +{{- with $serverURL -}} + {{- $adv = append $adv . -}} +{{- end -}} +{{- with $serverIngressURL -}} + {{- $adv = append $adv . -}} +{{- end -}} +{{- with $serverIngressURLPort -}} + {{- $adv = append $adv . -}} +{{- end -}} +{{- with .Values.plex.additionalAdvertiseURL -}} + {{- $adv = append $adv . -}} +{{- end -}} + +{{- $_ := set .Values.workload.main.podSpec.containers.main.env "ADVERTISE_IP" (join "," $adv) -}} {{/* Render the templates */}} -{{ include "tc.v1.common.loader.apply" . }} +{{- include "tc.v1.common.loader.apply" . -}} diff --git a/charts/stable/plex/values.yaml b/charts/stable/plex/values.yaml index 2ce76350f91..32890c0d2da 100644 --- a/charts/stable/plex/values.yaml +++ b/charts/stable/plex/values.yaml @@ -9,27 +9,45 @@ service: protocol: http port: 32400 targetPort: 32400 + persistence: config: enabled: true mountPath: "/config" + plex: # User Defined serverIP: "127.0.0.1" additionalAdvertiseURL: "" disableGDM: true - -portal: - open: - enabled: true + requireHTTPS: true workload: main: podSpec: containers: main: + probes: + liveness: + enabled: true + path: /identity + protocol: http + readiness: + enabled: true + path: /identity + protocol: http + startup: + enabled: true + path: /identity + protocol: http env: PLEX_PREFERENCE_GDM: 'GdmEnabled={{ ternary "0" "1" .Values.plex.disableGDM }}' + # 0=Required, 1=Preferred + PLEX_PREFERENCE_SEC_CON: 'secureConnections={{ ternary "0" "1" .Values.plex.requireHTTPS }}' # User Defined ALLOWED_NETWORKS: "172.16.0.0/12,10.0.0.0/8,192.168.0.0/16" PLEX_CLAIM: "" + +portal: + open: + enabled: true diff --git a/templates/questions/security/securityContextContainer.yaml b/templates/questions/security/securityContextContainer.yaml index 521550e64e9..451f5d43c79 100644 --- a/templates/questions/security/securityContextContainer.yaml +++ b/templates/questions/security/securityContextContainer.yaml @@ -4,7 +4,7 @@ description: When supported by the container, this sets the User ID running the Application Process. Not supported by all Apps schema: type: int - show_if: [["runAsUser", "=", "0"]] + show_if: [["runAsUser", "=", 0]] default: 568 - variable: UMASK label: UMASK