Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add commonLabels and commonAnnotations #65

Open
2 tasks done
ecthelion77 opened this issue Nov 25, 2021 · 1 comment
Open
2 tasks done

add commonLabels and commonAnnotations #65

ecthelion77 opened this issue Nov 25, 2021 · 1 comment

Comments

@ecthelion77
Copy link

ecthelion77 commented Nov 25, 2021

Preflight Checklist

  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Problem Description

No possibilities to define labels and annotation for resources in chart.

Proposed Solution

Best practice for helm chart development consists to add following metadata definitions on each template :

  labels:
    app.kubernetes.io/name: {{ template "dex.name" . }}
    helm.sh/chart: {{ template "dex.chart" . }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    {{- if .Values.commonLabels }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
    {{- end }}
  annotations:
    {{- if .Values.commonAnnotations }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
    {{- end }}

and following block in templates :

{{/* vim: set filetype=mustache: */}}
{{/*
Renders a value that contains template.
Usage:
{{ include "common.tplvalues.render" ( dict "value" .Values.path.to.the.Value "context" $) }}
*/}}
{{- define "common.tplvalues.render" -}}
    {{- if typeIs "string" .value }}
        {{- tpl .value .context }}
    {{- else }}
        {{- tpl (.value | toYaml) .context }}
    {{- end }}
{{- end -}}

(or integrate common helm chart from bitnami as dependency: https://artifacthub.io/packages/helm/bitnami/common)

Alternatives Considered

No response

Additional Information

No response

@ecthelion77
Copy link
Author

Pull request #67

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant