From b1c5ad67b5303cc5c1b397906784c4c980305682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20Ramalho?= Date: Tue, 18 Jan 2022 14:51:31 -0300 Subject: [PATCH 1/3] Helm: move `dependencies` variables to `global` Declaring those variables as global enables cross-referencing variables from lower level charts through the parent helm chart. --- packaging/helm/trento-server/Chart.yaml | 6 +++--- .../trento-server/charts/trento-runner/Chart.yaml | 2 +- .../charts/trento-runner/templates/deployment.yaml | 4 ++-- .../trento-server/charts/trento-runner/values.yaml | 12 +++--------- .../helm/trento-server/charts/trento-web/Chart.yaml | 2 +- .../charts/trento-web/templates/_helpers.tpl | 11 +++++++++++ .../charts/trento-web/templates/deployment.yaml | 4 ++-- .../charts/trento-web/templates/ingress.yaml | 2 +- .../charts/trento-web/templates/webservice.yaml | 2 +- .../helm/trento-server/charts/trento-web/values.yaml | 11 +++++------ packaging/helm/trento-server/values.yaml | 9 ++++++--- 11 files changed, 36 insertions(+), 29 deletions(-) diff --git a/packaging/helm/trento-server/Chart.yaml b/packaging/helm/trento-server/Chart.yaml index 2df8c2d8f..90da3bb1e 100644 --- a/packaging/helm/trento-server/Chart.yaml +++ b/packaging/helm/trento-server/Chart.yaml @@ -1,12 +1,12 @@ -#!BuildTag: trento/trento-server:0.3.3 -#!BuildTag: trento/trento-server:0.3.3-build%RELEASE% +#!BuildTag: trento/trento-server:0.3.4 +#!BuildTag: trento/trento-server:0.3.4-build%RELEASE% apiVersion: v2 name: trento-server description: The trento server chart contains all the components necessary to run a Trento server. type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates -version: 0.3.3 +version: 0.3.4 dependencies: - name: trento-web diff --git a/packaging/helm/trento-server/charts/trento-runner/Chart.yaml b/packaging/helm/trento-server/charts/trento-runner/Chart.yaml index a0b8c7847..c5ffce1e7 100644 --- a/packaging/helm/trento-server/charts/trento-runner/Chart.yaml +++ b/packaging/helm/trento-server/charts/trento-runner/Chart.yaml @@ -15,4 +15,4 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.3.4 +version: 0.3.5 diff --git a/packaging/helm/trento-server/charts/trento-runner/templates/deployment.yaml b/packaging/helm/trento-server/charts/trento-runner/templates/deployment.yaml index 419539612..9adbcd391 100644 --- a/packaging/helm/trento-server/charts/trento-runner/templates/deployment.yaml +++ b/packaging/helm/trento-server/charts/trento-runner/templates/deployment.yaml @@ -34,9 +34,9 @@ spec: - name: TRENTO_LOG_LEVEL value: "{{ .Values.global.logLevel }}" - name: TRENTO_API_HOST - value: "{{ .Release.Name }}-{{ .Values.dependencies.trentoWeb.name }}" + value: "{{ .Release.Name }}-{{ .Values.global.trentoWeb.name }}" - name: TRENTO_API_PORT - value: "{{ .Values.dependencies.trentoWeb.port }}" + value: "{{ .Values.global.trentoWeb.servicePort }}" - name: TRENTO_INTERVAL value: "{{ .Values.checkIntervalMins }}" args: diff --git a/packaging/helm/trento-server/charts/trento-runner/values.yaml b/packaging/helm/trento-server/charts/trento-runner/values.yaml index 6e11a52a8..cf688e384 100644 --- a/packaging/helm/trento-server/charts/trento-runner/values.yaml +++ b/packaging/helm/trento-server/charts/trento-runner/values.yaml @@ -4,6 +4,9 @@ global: logLevel: info + trentoWeb: + name: web + servicePort: 8080 privateKey: "" checkIntervalMins: 5 @@ -81,12 +84,3 @@ nodeSelector: {} tolerations: [] affinity: {} - -# service dependencies to be consumed by the runner deployment -dependencies: - trentoWeb: - name: trento-web - port: 8080 - trentoCollector: - name: trento-web-collector - port: 8081 diff --git a/packaging/helm/trento-server/charts/trento-web/Chart.yaml b/packaging/helm/trento-server/charts/trento-web/Chart.yaml index 13c9f2c40..5698f5cd9 100644 --- a/packaging/helm/trento-server/charts/trento-web/Chart.yaml +++ b/packaging/helm/trento-server/charts/trento-web/Chart.yaml @@ -15,4 +15,4 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.3.6 +version: 0.3.7 diff --git a/packaging/helm/trento-server/charts/trento-web/templates/_helpers.tpl b/packaging/helm/trento-server/charts/trento-web/templates/_helpers.tpl index f1729a8c5..1b9e7ae5c 100644 --- a/packaging/helm/trento-server/charts/trento-web/templates/_helpers.tpl +++ b/packaging/helm/trento-server/charts/trento-web/templates/_helpers.tpl @@ -60,3 +60,14 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + +{{/* +Return Trento Web service port +*/}} +{{- define "trentoWeb.port" -}} +{{- if .Values.global.trentoWeb.servicePort }} + {{- .Values.global.trentoWeb.servicePort -}} +{{- else -}} + {{- .Values.webService.port -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/packaging/helm/trento-server/charts/trento-web/templates/deployment.yaml b/packaging/helm/trento-server/charts/trento-web/templates/deployment.yaml index 9040ceb70..e312347db 100644 --- a/packaging/helm/trento-server/charts/trento-web/templates/deployment.yaml +++ b/packaging/helm/trento-server/charts/trento-web/templates/deployment.yaml @@ -34,9 +34,9 @@ spec: - name: TRENTO_LOG_LEVEL value: "{{ .Values.global.logLevel }}" - name: TRENTO_DB_HOST - value: "{{ .Release.Name }}-{{ .Values.dependencies.postgresql.name }}" + value: "{{ .Release.Name }}-{{ .Values.global.postgresql.name }}" - name: TRENTO_DB_PORT - value: "{{ .Values.dependencies.postgresql.port }}" + value: "{{ .Values.global.postgresql.servicePort }}" - name: TRENTO_PORT value: "{{ .Values.webService.port }}" - name: TRENTO_COLLECTOR_PORT diff --git a/packaging/helm/trento-server/charts/trento-web/templates/ingress.yaml b/packaging/helm/trento-server/charts/trento-web/templates/ingress.yaml index d813367ab..70635761a 100644 --- a/packaging/helm/trento-server/charts/trento-web/templates/ingress.yaml +++ b/packaging/helm/trento-server/charts/trento-web/templates/ingress.yaml @@ -1,6 +1,6 @@ {{- if .Values.ingress.enabled -}} {{- $fullName := include "trento-web.fullname" . -}} -{{- $svcPort := .Values.webService.port -}} +{{- $svcPort := include "trentoWeb.port" . -}} {{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} diff --git a/packaging/helm/trento-server/charts/trento-web/templates/webservice.yaml b/packaging/helm/trento-server/charts/trento-web/templates/webservice.yaml index b25c570bf..90d6f3144 100644 --- a/packaging/helm/trento-server/charts/trento-web/templates/webservice.yaml +++ b/packaging/helm/trento-server/charts/trento-web/templates/webservice.yaml @@ -7,7 +7,7 @@ metadata: spec: type: {{ .Values.webService.type }} ports: - - port: {{ .Values.webService.port }} + - port: {{ template "trentoWeb.port" . }} targetPort: http protocol: TCP name: http diff --git a/packaging/helm/trento-server/charts/trento-web/values.yaml b/packaging/helm/trento-server/charts/trento-web/values.yaml index f3ab3e291..dbba19d8e 100644 --- a/packaging/helm/trento-server/charts/trento-web/values.yaml +++ b/packaging/helm/trento-server/charts/trento-web/values.yaml @@ -4,6 +4,11 @@ global: logLevel: info + trentoWeb: + servicePort: "" + postgresql: + name: postgresql + servicePort: 5432 mTLS: enabled: false @@ -98,9 +103,3 @@ nodeSelector: {} tolerations: [] affinity: {} - -# service dependencies to be consumed by the web deployment -dependencies: - postgresql: - name: postgresql - port: 5432 diff --git a/packaging/helm/trento-server/values.yaml b/packaging/helm/trento-server/values.yaml index b0d34cf5f..866c333ad 100644 --- a/packaging/helm/trento-server/values.yaml +++ b/packaging/helm/trento-server/values.yaml @@ -1,6 +1,12 @@ ### Global Values ### global: logLevel: info + trentoWeb: + name: web + servicePort: 8080 + postgresql: + name: postgresql + servicePort: 5432 ### Sub Charts Specific Values ### trento-web: @@ -10,9 +16,6 @@ trento-web: trento-runner: nameOverride: runner enabled: true - dependencies: - trentoWeb: - name: web postgresql: enabled: true From 57810391540f191aba0ff205b291bc02cae34239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20Ramalho?= Date: Tue, 18 Jan 2022 15:32:19 -0300 Subject: [PATCH 2/3] Helm: lint subcharts Also lint subcharts. --- ct.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/ct.yaml b/ct.yaml index 684ecce12..dea9f4e01 100644 --- a/ct.yaml +++ b/ct.yaml @@ -1,5 +1,6 @@ # https://github.com/helm/chart-testing chart-dirs: + - packaging/helm/trento-server/charts - packaging/helm chart-repos: - bitnami=https://charts.bitnami.com/bitnami From a7f267b08b3b7a9e9457d97cdea79663e3f019a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20Ramalho?= Date: Tue, 18 Jan 2022 15:52:52 -0300 Subject: [PATCH 3/3] Helm: fix certificate secret name --- .../helm/trento-server/charts/trento-web/templates/certs.yaml | 2 +- .../trento-server/charts/trento-web/templates/deployment.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/helm/trento-server/charts/trento-web/templates/certs.yaml b/packaging/helm/trento-server/charts/trento-web/templates/certs.yaml index f5f36d81f..65d857e95 100644 --- a/packaging/helm/trento-server/charts/trento-web/templates/certs.yaml +++ b/packaging/helm/trento-server/charts/trento-web/templates/certs.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: Secret metadata: - name: {{ include "trento-runner.fullname" . }}-certs + name: {{ include "trento-web.fullname" . }}-certs data: cert: |- {{ .Values.mTLS.cert | b64enc }} diff --git a/packaging/helm/trento-server/charts/trento-web/templates/deployment.yaml b/packaging/helm/trento-server/charts/trento-web/templates/deployment.yaml index e312347db..7af35de95 100644 --- a/packaging/helm/trento-server/charts/trento-web/templates/deployment.yaml +++ b/packaging/helm/trento-server/charts/trento-web/templates/deployment.yaml @@ -94,7 +94,7 @@ spec: volumes: - name: certs secret: - secretName: {{ include "trento-runner.fullname" . }}-certs + secretName: {{ include "trento-web.fullname" . }}-certs items: - key: cert path: cert.pem