Search code examples
kuberneteskubernetes-helm

Helm, Is there a way to add kubernetes labels to values.yaml (without using template and _helpers.tpl)


So as in the title, I would like to add labels to my helms of my already running applications (sonarqube and jenkins from official helm charts). I don't have templates in them just values.yaml. I am afraid of adding templates, because as I said, application is already running and I just want to add few labels in metadata.


Solution

  • Both charts mentioned in comment under question has a way to define custom labels

    https://github.com/jenkinsci/helm-charts/blob/main/charts/jenkins/templates/jenkins-master-deployment.yaml#L42

        {{- range $key, $val := .Values.master.podLabels }}
        {{ $key }}: {{ $val | quote }}
        {{- end}}
    

    https://github.com/Oteemo/charts/blob/master/charts/sonarqube/templates/deployment.yaml#L31

    {{- with .Values.podLabels }}
    {{ toYaml . | indent 8 }}
    {{- end }}
    

    So you need something like this in values.yaml

    # Jenkins
    master:
      podLabels:
        label1Name: label1Value
    
    # Sonar
    podLabels:
      label1Name: label1Value