From 40d707f381f469d8d67757ecbe31799342c9aa0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Valais?= Date: Fri, 19 Jul 2024 11:40:06 +0200 Subject: [PATCH 1/3] helm: add omitHelmLabels so that people can generate static manifests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maƫl Valais --- .gitignore | 1 + deploy/charts/openshift-routes/README.md | 7 +++++++ .../openshift-routes/templates/_helpers.tpl | 15 ++++++++++++--- deploy/charts/openshift-routes/values.schema.json | 8 ++++++++ deploy/charts/openshift-routes/values.yaml | 6 +++++- 5 files changed, 33 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 40111d3..f8845f3 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ *.dylib _bin bin +dist/ # Test binary, build with `go test -c` *.test diff --git a/deploy/charts/openshift-routes/README.md b/deploy/charts/openshift-routes/README.md index acf23b1..2533f72 100644 --- a/deploy/charts/openshift-routes/README.md +++ b/deploy/charts/openshift-routes/README.md @@ -216,5 +216,12 @@ Create a ServiceMonitor to add openshift-routes to Prometheus. > ``` The interval to scrape metrics. +#### **omitHelmLabels** ~ `bool` +> Default value: +> ```yaml +> false +> ``` + +Omit Helm-specific labels. This is useful when generating a static manifest with `helm template`. \ No newline at end of file diff --git a/deploy/charts/openshift-routes/templates/_helpers.tpl b/deploy/charts/openshift-routes/templates/_helpers.tpl index b253bc6..944e964 100644 --- a/deploy/charts/openshift-routes/templates/_helpers.tpl +++ b/deploy/charts/openshift-routes/templates/_helpers.tpl @@ -48,10 +48,15 @@ https://github.com/helm/helm/issues/5358. Common labels */}} {{- define "openshift-routes.labels" -}} -helm.sh/chart: {{ include "openshift-routes.chart" . }} -{{ include "openshift-routes.selectorLabels" . }} -app.kubernetes.io/component: controller +{{/* +You can generate generate a static manifest free of Helm-specific labels by +using `--set omitHelmLabels=true`. +*/}} +{{- include "openshift-routes.selectorLabels" . }} +{{- if not .Values.omitHelmLabels }} app.kubernetes.io/managed-by: {{ .Release.Service }} +helm.sh/chart: {{ include "openshift-routes.chart" . }} +{{- end }} {{- end }} {{/* @@ -59,7 +64,11 @@ Selector labels */}} {{- define "openshift-routes.selectorLabels" -}} app.kubernetes.io/name: {{ include "openshift-routes.name" . }} +app.kubernetes.io/component: controller +app.kubernetes.io/version: {{ .Chart.AppVersion }} +{{- if not .Values.omitHelmLabels }} app.kubernetes.io/instance: {{ .Release.Name }} +{{- end}} {{- end }} {{/* diff --git a/deploy/charts/openshift-routes/values.schema.json b/deploy/charts/openshift-routes/values.schema.json index 27cb457..4727b29 100644 --- a/deploy/charts/openshift-routes/values.schema.json +++ b/deploy/charts/openshift-routes/values.schema.json @@ -33,6 +33,9 @@ "nodeSelector": { "$ref": "#/$defs/helm-values.nodeSelector" }, + "omitHelmLabels": { + "$ref": "#/$defs/helm-values.omitHelmLabels" + }, "podAnnotations": { "$ref": "#/$defs/helm-values.podAnnotations" }, @@ -180,6 +183,11 @@ "description": "The nodeSelector on Pods tells Kubernetes to schedule Pods on the nodes with matching labels. For more information, see [Assigning Pods to Nodes](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/).\n\nThis default ensures that Pods are only scheduled to Linux nodes. It prevents Pods being scheduled to Windows nodes in a mixed OS cluster.", "type": "object" }, + "helm-values.omitHelmLabels": { + "default": false, + "description": "Omit Helm-specific labels. This is useful when generating a static manifest with `helm template`.", + "type": "boolean" + }, "helm-values.podAnnotations": { "default": {}, "description": "Annotations to add to the openshift-routes pod.", diff --git a/deploy/charts/openshift-routes/values.yaml b/deploy/charts/openshift-routes/values.yaml index 0995474..ee66c33 100644 --- a/deploy/charts/openshift-routes/values.yaml +++ b/deploy/charts/openshift-routes/values.yaml @@ -84,7 +84,7 @@ securityContext: allowPrivilegeEscalation: false capabilities: drop: - - ALL + - ALL readOnlyRootFilesystem: true # Kubernetes pod resources @@ -143,3 +143,7 @@ metrics: # The interval to scrape metrics. interval: 60s + +# Omit Helm-specific labels. This is useful when generating a static manifest +# with `helm template`. +omitHelmLabels: false From b36d5372ac760ee3a70414e02ce7abdcc3b0d0d1 Mon Sep 17 00:00:00 2001 From: Tim Ramlot <42113979+inteon@users.noreply.github.com> Date: Mon, 12 Aug 2024 09:43:44 +0200 Subject: [PATCH 2/3] don't use version label in Delployment label selector Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com> --- deploy/charts/openshift-routes/templates/_helpers.tpl | 2 +- deploy/charts/openshift-routes/templates/deployment.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/deploy/charts/openshift-routes/templates/_helpers.tpl b/deploy/charts/openshift-routes/templates/_helpers.tpl index 944e964..de10fc7 100644 --- a/deploy/charts/openshift-routes/templates/_helpers.tpl +++ b/deploy/charts/openshift-routes/templates/_helpers.tpl @@ -53,6 +53,7 @@ You can generate generate a static manifest free of Helm-specific labels by using `--set omitHelmLabels=true`. */}} {{- include "openshift-routes.selectorLabels" . }} +app.kubernetes.io/version: {{ .Chart.AppVersion }} {{- if not .Values.omitHelmLabels }} app.kubernetes.io/managed-by: {{ .Release.Service }} helm.sh/chart: {{ include "openshift-routes.chart" . }} @@ -65,7 +66,6 @@ Selector labels {{- define "openshift-routes.selectorLabels" -}} app.kubernetes.io/name: {{ include "openshift-routes.name" . }} app.kubernetes.io/component: controller -app.kubernetes.io/version: {{ .Chart.AppVersion }} {{- if not .Values.omitHelmLabels }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end}} diff --git a/deploy/charts/openshift-routes/templates/deployment.yaml b/deploy/charts/openshift-routes/templates/deployment.yaml index e8bd914..ae3f435 100644 --- a/deploy/charts/openshift-routes/templates/deployment.yaml +++ b/deploy/charts/openshift-routes/templates/deployment.yaml @@ -17,7 +17,7 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} labels: - {{- include "openshift-routes.selectorLabels" . | nindent 8 }} + {{- include "openshift-routes.labels" . | nindent 8 }} spec: automountServiceAccountToken: true {{- with .Values.imagePullSecrets }} From 80614e7bb7900c7937f981ec77536f1468f0c51e Mon Sep 17 00:00:00 2001 From: Tim Ramlot <42113979+inteon@users.noreply.github.com> Date: Wed, 14 Aug 2024 10:35:36 +0200 Subject: [PATCH 3/3] make sure we use the same selectorLabels as used in 0.5.0 Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com> --- deploy/charts/openshift-routes/templates/_helpers.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/charts/openshift-routes/templates/_helpers.tpl b/deploy/charts/openshift-routes/templates/_helpers.tpl index de10fc7..1896693 100644 --- a/deploy/charts/openshift-routes/templates/_helpers.tpl +++ b/deploy/charts/openshift-routes/templates/_helpers.tpl @@ -54,6 +54,7 @@ using `--set omitHelmLabels=true`. */}} {{- include "openshift-routes.selectorLabels" . }} app.kubernetes.io/version: {{ .Chart.AppVersion }} +app.kubernetes.io/component: controller {{- if not .Values.omitHelmLabels }} app.kubernetes.io/managed-by: {{ .Release.Service }} helm.sh/chart: {{ include "openshift-routes.chart" . }} @@ -65,7 +66,6 @@ Selector labels */}} {{- define "openshift-routes.selectorLabels" -}} app.kubernetes.io/name: {{ include "openshift-routes.name" . }} -app.kubernetes.io/component: controller {{- if not .Values.omitHelmLabels }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end}}