From 5132df548cf0efeb70b8baaafb16c5175d6c2fd4 Mon Sep 17 00:00:00 2001 From: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Date: Tue, 9 May 2023 14:21:00 +0300 Subject: [PATCH] NAS-121749 / 23.10 / Apply a partial fix for hostnetwork toggling (#1166) * Apply a partial fix for hostnetwork toggling * gh hightlighting * fix test * apply it to few more apps * update comment * bump changed apps * add mail attrib * bump apps --- library/common-test/Chart.yaml | 1 + .../tests/container/ports_test.yaml | 5 +++++ library/common/Chart.yaml | 3 ++- .../common/templates/lib/container/_ports.tpl | 11 ++++++++-- library/ix-dev/charts/emby/Chart.yaml | 2 +- .../charts/emby/templates/deployment.yaml | 9 +++++++++ .../ix-dev/charts/home-assistant/Chart.yaml | 2 +- .../home-assistant/templates/deployment.yaml | 3 +++ library/ix-dev/charts/plex/Chart.yaml | 2 +- .../charts/plex/templates/deployment.yaml | 20 +++++++++++++++++++ library/ix-dev/charts/syncthing/Chart.yaml | 2 +- .../syncthing/templates/deployment.yaml | 9 +++++++++ library/ix-dev/charts/wg-easy/Chart.yaml | 2 +- .../charts/wg-easy/templates/deployment.yaml | 6 ++++++ 14 files changed, 69 insertions(+), 8 deletions(-) diff --git a/library/common-test/Chart.yaml b/library/common-test/Chart.yaml index f8bea64689..b64b91e0fc 100644 --- a/library/common-test/Chart.yaml +++ b/library/common-test/Chart.yaml @@ -16,3 +16,4 @@ dependencies: maintainers: - name: truenas url: https://www.truenas.com/ + email: dev@ixsystems.com diff --git a/library/common-test/tests/container/ports_test.yaml b/library/common-test/tests/container/ports_test.yaml index 6523d5b222..905c89d74b 100644 --- a/library/common-test/tests/container/ports_test.yaml +++ b/library/common-test/tests/container/ports_test.yaml @@ -61,6 +61,7 @@ tests: ports: - name: port-name containerPort: 80 + hostPort: null protocol: TCP - documentIndex: &otherDeploymentDoc 1 isKind: @@ -135,6 +136,7 @@ tests: ports: - name: port-name containerPort: 1234 + hostPort: null protocol: TCP - documentIndex: &otherDeploymentDoc 1 isKind: @@ -146,6 +148,7 @@ tests: ports: - name: port-name containerPort: 53 + hostPort: null protocol: TCP - it: should create the correct ports with hostPort @@ -237,6 +240,7 @@ tests: ports: - name: port-name containerPort: 1234 + hostPort: null protocol: TCP - it: should create the correct protocol @@ -281,4 +285,5 @@ tests: ports: - name: port-name containerPort: 1234 + hostPort: null protocol: UDP diff --git a/library/common/Chart.yaml b/library/common/Chart.yaml index 0c2cfff5d6..a1d497477e 100644 --- a/library/common/Chart.yaml +++ b/library/common/Chart.yaml @@ -2,10 +2,11 @@ apiVersion: v2 name: common description: A library chart for iX Official Catalog type: library -version: 1.0.6 +version: 1.0.7 appVersion: v1 annotations: title: Common Library Chart maintainers: - name: truenas url: https://www.truenas.com/ + email: dev@ixsystems.com diff --git a/library/common/templates/lib/container/_ports.tpl b/library/common/templates/lib/container/_ports.tpl index e6a6cf10ae..3d91481e74 100644 --- a/library/common/templates/lib/container/_ports.tpl +++ b/library/common/templates/lib/container/_ports.tpl @@ -45,7 +45,7 @@ objectData: The object data to be used to render the container. {{- end -}} {{- else -}} - {{/* If no selector is defined but contaienr is primary */}} + {{/* If no selector is defined but container is primary */}} {{- if $objectData.primary -}} {{- $containerSelected = true -}} {{- end -}} @@ -68,8 +68,10 @@ objectData: The object data to be used to render the container. - name: {{ $portName }} containerPort: {{ $containerPort }} protocol: {{ $protocol | upper }} - {{- with $portValues.hostPort }} + {{- with $portValues.hostPort }} hostPort: {{ . }} + {{- else }} + hostPort: null {{- end -}} {{- end -}} @@ -78,3 +80,8 @@ objectData: The object data to be used to render the container. {{- end -}} {{- end -}} +{{/* Turning hostNetwork on, it creates hostPort automatically and turning it back off does not remove them. Setting hostPort explicitly to null will remove them. + There are still cases that hostPort is not removed, for example, if you have a TCP and UDP port with the same port number. Only the one of the hostPorts will + be removed. This is due to how merging is happening, (See kubernetes/kubernetes#105610). Also note that setting hostPort to null always, it will NOT affect + hostNetwork, as it will still create the hostPorts. It only helps to remove them when hostNetwork is turned off. +*/}} diff --git a/library/ix-dev/charts/emby/Chart.yaml b/library/ix-dev/charts/emby/Chart.yaml index d8e5fe52f6..9cb8143f0d 100644 --- a/library/ix-dev/charts/emby/Chart.yaml +++ b/library/ix-dev/charts/emby/Chart.yaml @@ -3,7 +3,7 @@ description: Emby Server annotations: title: Emby Server type: application -version: 1.0.22 +version: 1.0.23 apiVersion: v2 appVersion: '4.7.11.0' kubeVersion: '>=1.16.0-0' diff --git a/library/ix-dev/charts/emby/templates/deployment.yaml b/library/ix-dev/charts/emby/templates/deployment.yaml index 0c6f75db33..831f47c036 100644 --- a/library/ix-dev/charts/emby/templates/deployment.yaml +++ b/library/ix-dev/charts/emby/templates/deployment.yaml @@ -31,12 +31,21 @@ spec: {{ include "common.deployment.common_spec" . | nindent 2 }} - name: emby protocol: TCP containerPort: 8096 + {{- if not .Values.hostNetwork }} + hostPort: null + {{- end }} - name: emby-dlna protocol: UDP containerPort: 1900 + {{- if not .Values.hostNetwork }} + hostPort: null + {{- end }} - name: emby-lnd protocol: UDP containerPort: 7359 + {{- if not .Values.hostNetwork }} + hostPort: null + {{- end }} env: - name: KUBE_NAMESPACE valueFrom: diff --git a/library/ix-dev/charts/home-assistant/Chart.yaml b/library/ix-dev/charts/home-assistant/Chart.yaml index e23b9035fb..ead3805afc 100644 --- a/library/ix-dev/charts/home-assistant/Chart.yaml +++ b/library/ix-dev/charts/home-assistant/Chart.yaml @@ -3,7 +3,7 @@ description: Home Assistant App for TrueNAS SCALE annotations: title: Home Assistant type: application -version: 1.0.88 +version: 1.0.89 apiVersion: v2 appVersion: 2023.5.2 kubeVersion: '>=1.16.0-0' diff --git a/library/ix-dev/charts/home-assistant/templates/deployment.yaml b/library/ix-dev/charts/home-assistant/templates/deployment.yaml index 5df296fc28..ad026c2eb0 100644 --- a/library/ix-dev/charts/home-assistant/templates/deployment.yaml +++ b/library/ix-dev/charts/home-assistant/templates/deployment.yaml @@ -71,6 +71,9 @@ spec: ports: - name: web containerPort: 8123 + {{- if not .Values.hostNetwork }} + hostPort: null + {{- end }} readinessProbe: tcpSocket: port: 8123 diff --git a/library/ix-dev/charts/plex/Chart.yaml b/library/ix-dev/charts/plex/Chart.yaml index e64bc4e684..009177f2ce 100644 --- a/library/ix-dev/charts/plex/Chart.yaml +++ b/library/ix-dev/charts/plex/Chart.yaml @@ -3,7 +3,7 @@ description: Plex Media Server annotations: title: Plex type: application -version: 1.7.44 +version: 1.7.45 apiVersion: v2 appVersion: 1.32.1.6999 kubeVersion: '>=1.16.0-0' diff --git a/library/ix-dev/charts/plex/templates/deployment.yaml b/library/ix-dev/charts/plex/templates/deployment.yaml index a4071fff54..df09969f25 100644 --- a/library/ix-dev/charts/plex/templates/deployment.yaml +++ b/library/ix-dev/charts/plex/templates/deployment.yaml @@ -37,25 +37,45 @@ spec: {{ include "common.deployment.common_spec" . | nindent 2 }} containerPort: 32400 {{- if .Values.hostNetwork }} hostPort: {{ .Values.plexServiceTCP.port }} + {{- else }} + hostPort: null {{- end }} - name: plex-dlna protocol: TCP containerPort: 32469 + {{- if not .Values.hostNetwork }} + hostPort: null + {{- end }} - name: plex-dlna-udp protocol: UDP containerPort: 1900 + {{- if not .Values.hostNetwork }} + hostPort: null + {{- end }} - name: plex-gdm1 protocol: UDP containerPort: 32410 + {{- if not .Values.hostNetwork }} + hostPort: null + {{- end }} - name: plex-gdm2 protocol: UDP containerPort: 32412 + {{- if not .Values.hostNetwork }} + hostPort: null + {{- end }} - name: plex-gdm3 protocol: UDP containerPort: 32413 + {{- if not .Values.hostNetwork }} + hostPort: null + {{- end }} - name: plex-gdm4 protocol: UDP containerPort: 32414 + {{- if not .Values.hostNetwork }} + hostPort: null + {{- end }} env: - name: KUBE_NAMESPACE valueFrom: diff --git a/library/ix-dev/charts/syncthing/Chart.yaml b/library/ix-dev/charts/syncthing/Chart.yaml index a951249454..66f87e9081 100644 --- a/library/ix-dev/charts/syncthing/Chart.yaml +++ b/library/ix-dev/charts/syncthing/Chart.yaml @@ -3,7 +3,7 @@ description: Syncthing is a continuous file synchronization program. annotations: title: Syncthing type: application -version: 1.0.25 +version: 1.0.26 apiVersion: v2 appVersion: 1.23.4 kubeVersion: '>=1.16.0-0' diff --git a/library/ix-dev/charts/syncthing/templates/deployment.yaml b/library/ix-dev/charts/syncthing/templates/deployment.yaml index 916ed3020f..f43fccdd82 100644 --- a/library/ix-dev/charts/syncthing/templates/deployment.yaml +++ b/library/ix-dev/charts/syncthing/templates/deployment.yaml @@ -41,12 +41,21 @@ spec: ports: - name: web containerPort: 8384 + {{ if not .Values.hostNetwork }} + hostPort: null + {{ end }} - name: tcp containerPort: 22000 protocol: TCP + {{ if not .Values.hostNetwork }} + hostPort: null + {{ end }} - name: udp containerPort: 22000 protocol: UDP + {{ if not .Values.hostNetwork }} + hostPort: null + {{ end }} readinessProbe: httpGet: path: /rest/noauth/health diff --git a/library/ix-dev/charts/wg-easy/Chart.yaml b/library/ix-dev/charts/wg-easy/Chart.yaml index f5c9becc77..bc36dffbbf 100644 --- a/library/ix-dev/charts/wg-easy/Chart.yaml +++ b/library/ix-dev/charts/wg-easy/Chart.yaml @@ -3,7 +3,7 @@ description: WG-Easy is the easiest way to install & manage WireGuard! annotations: title: WG Easy type: application -version: 1.0.5 +version: 1.0.6 apiVersion: v2 appVersion: "7" kubeVersion: ">=1.16.0-0" diff --git a/library/ix-dev/charts/wg-easy/templates/deployment.yaml b/library/ix-dev/charts/wg-easy/templates/deployment.yaml index 0e113f75d8..94f2fe1ccf 100644 --- a/library/ix-dev/charts/wg-easy/templates/deployment.yaml +++ b/library/ix-dev/charts/wg-easy/templates/deployment.yaml @@ -50,8 +50,14 @@ spec: - name: udp containerPort: {{ .Values.wgUDPPort }} protocol: UDP + {{- if not .Values.hostNetwork }} + hostPort: null + {{- end }} - name: web containerPort: {{ .Values.webUIPort }} + {{- if not .Values.hostNetwork }} + hostPort: null + {{- end }} env: {{ $wgeasy := .Values.wgeasy }} {{ $envList := (default list .Values.environmentVariables) }}