Skip to content

Feature: [Helm Chart] Add custom labels to resources #703

Open
@ejstreet

Description

@ejstreet

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:

{{/*
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, so a new labels variable should not affect the selector.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions