Skip to content

Commit

Permalink
Merge pull request #74 from maelvls/static-manifest
Browse files Browse the repository at this point in the history
Helm: add `omitHelmLabels` so that people can generate static manifests without the Helm-specific labels
  • Loading branch information
cert-manager-prow[bot] authored Aug 14, 2024
2 parents 71de67a + 80614e7 commit cfdfe89
Show file tree
Hide file tree
Showing 6 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 -->
13 changes: 11 additions & 2 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" . }}
{{/*
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 }}

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

{{/*
Expand Down
2 changes: 1 addition & 1 deletion deploy/charts/openshift-routes/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
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 cfdfe89

Please sign in to comment.