Skip to content

Commit

Permalink
helm: add omitHelmLabels so that people can generate static manifests
Browse files Browse the repository at this point in the history
Signed-off-by: Maël Valais <[email protected]>
  • Loading branch information
maelvls authored and inteon committed Aug 12, 2024
1 parent b706985 commit 40d707f
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*.dylib
_bin
bin
dist/

# Test binary, build with `go test -c`
*.test
Expand Down
7 changes: 7 additions & 0 deletions deploy/charts/openshift-routes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
<!-- /AUTO-GENERATED -->
15 changes: 12 additions & 3 deletions deploy/charts/openshift-routes/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,27 @@ 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 }}

{{/*
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 }}

{{/*
Expand Down
8 changes: 8 additions & 0 deletions deploy/charts/openshift-routes/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
"nodeSelector": {
"$ref": "#/$defs/helm-values.nodeSelector"
},
"omitHelmLabels": {
"$ref": "#/$defs/helm-values.omitHelmLabels"
},
"podAnnotations": {
"$ref": "#/$defs/helm-values.podAnnotations"
},
Expand Down Expand Up @@ -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.",
Expand Down
6 changes: 5 additions & 1 deletion deploy/charts/openshift-routes/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
- ALL
readOnlyRootFilesystem: true

# Kubernetes pod resources
Expand Down Expand Up @@ -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

0 comments on commit 40d707f

Please sign in to comment.