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..1896693 100644 --- a/deploy/charts/openshift-routes/templates/_helpers.tpl +++ b/deploy/charts/openshift-routes/templates/_helpers.tpl @@ -48,10 +48,17 @@ https://github.com/helm/helm/issues/5358. Common labels */}} {{- define "openshift-routes.labels" -}} -helm.sh/chart: {{ include "openshift-routes.chart" . }} -{{ include "openshift-routes.selectorLabels" . }} +{{/* +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 }} app.kubernetes.io/component: controller +{{- if not .Values.omitHelmLabels }} app.kubernetes.io/managed-by: {{ .Release.Service }} +helm.sh/chart: {{ include "openshift-routes.chart" . }} +{{- end }} {{- end }} {{/* @@ -59,7 +66,9 @@ Selector labels */}} {{- define "openshift-routes.selectorLabels" -}} app.kubernetes.io/name: {{ include "openshift-routes.name" . }} +{{- if not .Values.omitHelmLabels }} app.kubernetes.io/instance: {{ .Release.Name }} +{{- end}} {{- 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 }} 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