github-community-projects / github-community-projects/safe-settings
Feature: [Helm Chart] Add custom labels to resources
- Dominant language
- JavaScript
- Stars
- 921
- Forks
- 226
- Avg merge
- 18h 3m
- Merged PRs (30d)
- 14
Description
## New Feature
The Helm chart does not currently provide an easy way to add additional labels to resources. I would like to be able to pass a `commonLabels` variable or similar that can be appended to all resources created by the chart, particularly in the Deployment and pod template.
### Workaround
I have a partial workaround, which is to override the helper template in a wrapper chart like so, which will add labels to the deployment and the pod template:
```yaml
{{/*
Selector labels
*/}}
{{- define "safe-settings.selectorLabels" -}}
{{- range $key, $value := .Values.commonLabels }}
{{ $key }}: {{ $value }}
{{- end }}
app.kubernetes.io/name: {{ include "safe-settings.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
```
However, this has the drawback of forcing a replacement of the deployment if I ever wish to change a label, as [spec.selector is immutable](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#selector), so a new labels variable should not affect the selector.
Contributor guide
Assessment
This issue has not been assessed yet.