From 4a507b044d6e744e525fafc4e6e7cfdbe8df9c38 Mon Sep 17 00:00:00 2001 From: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Date: Wed, 22 Nov 2023 01:54:06 +0200 Subject: [PATCH] chore(nextcloud): add hostAliases to NC and collabora pods (#15234) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Description** ⚒️ Fixes # **⚙️ Type of change** - [ ] ⚙️ Feature/App addition - [x] 🪛 Bugfix - [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [x] 🔃 Refactor of current code **🧪 How Has This Been Tested?** **📃 Notes:** **✔️ Checklist:** - [x] ⚖️ My code follows the style guidelines of this project - [x] 👀 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 - [x] ⚠️ My changes generate no new warnings - [ ] 🧪 I have added tests to this description that prove my fix is effective or that my feature works - [x] ⬆️ 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._ --- charts/stable/nextcloud/Chart.yaml | 2 +- charts/stable/nextcloud/ci/basic-values.yaml | 2 + .../stable/nextcloud/templates/_configmap.tpl | 43 ++++++++++++------- charts/stable/nextcloud/templates/common.yaml | 12 ++++++ 4 files changed, 43 insertions(+), 16 deletions(-) diff --git a/charts/stable/nextcloud/Chart.yaml b/charts/stable/nextcloud/Chart.yaml index d2379be2949..eba6b27652b 100644 --- a/charts/stable/nextcloud/Chart.yaml +++ b/charts/stable/nextcloud/Chart.yaml @@ -29,7 +29,7 @@ sources: - https://github.com/nextcloud/docker - https://github.com/nextcloud/helm type: application -version: 22.2.4 +version: 22.2.5 annotations: truecharts.org/category: cloud truecharts.org/SCALE-support: "true" diff --git a/charts/stable/nextcloud/ci/basic-values.yaml b/charts/stable/nextcloud/ci/basic-values.yaml index 5ec603bf6ba..e5824f12c69 100644 --- a/charts/stable/nextcloud/ci/basic-values.yaml +++ b/charts/stable/nextcloud/ci/basic-values.yaml @@ -3,3 +3,5 @@ nextcloud: enabled: true collabora: enabled: true + general: + accessIP: 127.0.0.1 diff --git a/charts/stable/nextcloud/templates/_configmap.tpl b/charts/stable/nextcloud/templates/_configmap.tpl index d5a8796add2..66b01c3ae83 100644 --- a/charts/stable/nextcloud/templates/_configmap.tpl +++ b/charts/stable/nextcloud/templates/_configmap.tpl @@ -1,22 +1,35 @@ +{{- define "nextcloud.accessurl" -}} + {{- $accessUrl := .Values.chartContext.APPURL -}} + {{- if or (contains "127.0.0.1" $accessUrl) (contains "localhost" $accessUrl) -}} + {{- if .Values.nextcloud.general.accessIP -}} + {{- $prot := "http" -}} + {{- $host := .Values.nextcloud.general.accessIP -}} + {{- $port := .Values.service.main.ports.main.port -}} + {{/* + Allowing here to override protocol and port + should be enough to make it work with any rev proxy + */}} + {{- $accessUrl = printf "%v://%v:%v" $prot $host $port -}} + {{- end -}} + {{- end -}} + + {{- $accessUrl -}} +{{- end -}} + +{{- define "nextcloud.accesshost" -}} + {{- $accessUrl := (include "nextcloud.accessurl" $) -}} + {{- $accessHost := regexReplaceAll ".*://(.*)" $accessUrl "${1}" -}} + {{- $accessHost = regexReplaceAll "(.*):.*" $accessHost "${1}" -}} + + {{- $accessHost -}} +{{- end -}} + {{/* Define the configmap */}} {{- define "nextcloud.configmaps" -}} {{- $fullname := (include "tc.v1.common.lib.chart.names.fullname" $) -}} {{- $fqdn := (include "tc.v1.common.lib.chart.names.fqdn" $) -}} -{{- $accessUrl := .Values.chartContext.APPURL -}} -{{- if or (contains "127.0.0.1" $accessUrl) (contains "localhost" $accessUrl) -}} - {{- if .Values.nextcloud.general.accessIP -}} - {{- $prot := "http" -}} - {{- $host := .Values.nextcloud.general.accessIP -}} - {{- $port := .Values.service.main.ports.main.port -}} - {{/* - Allowing here to override protocol and port - should be enough to make it work with any rev proxy - */}} - {{- $accessUrl = printf "%v://%v:%v" $prot $host $port -}} - {{- end -}} -{{- end -}} -{{- $accessHost := regexReplaceAll ".*://(.*)" $accessUrl "${1}" -}} -{{- $accessHost = regexReplaceAll "(.*):.*" $accessUrl "${1}" -}} +{{- $accessUrl := (include "nextcloud.accessurl" $) -}} +{{- $accessHost := (include "nextcloud.accesshost" $) -}} {{- $accessHostPort := regexReplaceAll ".*://(.*)" $accessUrl "${1}" -}} {{- $accessProtocol := regexReplaceAll "(.*)://.*" $accessUrl "${1}" -}} {{- $redisHost := .Values.redis.creds.plainhost | trimAll "\"" -}} diff --git a/charts/stable/nextcloud/templates/common.yaml b/charts/stable/nextcloud/templates/common.yaml index 22ed3e0e564..1eeaf033ebe 100644 --- a/charts/stable/nextcloud/templates/common.yaml +++ b/charts/stable/nextcloud/templates/common.yaml @@ -9,6 +9,18 @@ {{- $_ := mustMergeOverwrite .Values.configmap $configmaps -}} {{- end -}} +{{/* Create hostAliases (resolve ingress host to Node/LB IP) */}} +{{- $hostAlias := (list (dict + "ip" .Values.nextcloud.general.accessIP + "hostnames" ( + list (include "nextcloud.accesshost" $) + ) + )) -}} + +{{/* Add [hostAliases] to nextcloud and collabora pod */}} +{{- $_ := set .Values.workload.main.podSpec "hostAliases" $hostAlias -}} +{{- $_ := set .Values.workload.collabora.podSpec "hostAliases" $hostAlias -}} + {{/* Add [init perms] container to nextcloud */}} {{- if not (get .Values.workload.main.podSpec "initContainers") -}} {{- $_ := set .Values.workload.main.podSpec "initContainers" dict -}}