Skip to content

Commit

Permalink
charts/daemonset add global labels (closes #181)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianarsenault committed Jul 31, 2024
1 parent a692afc commit 58d8346
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 4 deletions.
2 changes: 1 addition & 1 deletion charts/daemonset/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: daemonset
description: A Helm Chart to deploy an arbitrary container as a daemonset.
version: 0.3.2
version: 0.4.0
icon: https://raw.githubusercontent.com/snowplow-devops/helm-charts/master/docs/logo/snowplow.png
home: https://github.com/snowplow-devops/helm-charts
sources:
Expand Down
21 changes: 21 additions & 0 deletions charts/daemonset/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,24 @@ If release name contains chart name it will be used as a full name.
{{- define "app.secret.fullname" -}}
{{ include "app.fullname" . }}-secret
{{- end -}}

{{/*
Create chart name and version to use as chart label.
*/}}
{{- define "daemonset.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Snowplow labels
*/}}
{{- define "snowplow.labels" -}}
{{- with .Values.global.labels -}}
{{ toYaml . }}
{{ end -}}
helm.sh/chart: {{ include "daemonset.chart" . }}
{{- if .Chart.Version }}
app.kubernetes.io/version: {{ .Chart.Version | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
2 changes: 2 additions & 0 deletions charts/daemonset/templates/cluster_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "app.fullname" . }}
labels:
{{ include "snowplow.labels" $ | nindent 4 }}
rules:
{{- toYaml $.Values.clusterrole.rules | nindent 2 }}
---
Expand Down
2 changes: 2 additions & 0 deletions charts/daemonset/templates/cluster_role_binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "app.fullname" . }}
labels:
{{ include "snowplow.labels" $ | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down
2 changes: 2 additions & 0 deletions charts/daemonset/templates/configmaps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $v.name }}
labels:
{{ include "snowplow.labels" $ | nindent 4 }}
binaryData:
{{- range $f := $v.files }}
{{- if $f.contentsB64 }}
Expand Down
3 changes: 3 additions & 0 deletions charts/daemonset/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ apiVersion: apps/v1
kind: DaemonSet
metadata:
name: {{ include "app.fullname" . }}
labels:
{{ include "snowplow.labels" $ | nindent 4 }}
spec:
selector:
matchLabels:
app: {{ include "app.fullname" . }}
template:
metadata:
labels:
{{ include "snowplow.labels" $ | nindent 8 }}
app: {{ include "app.fullname" . }}
{{- if eq .Values.global.cloud "azure" }}
azure.workload.identity/use: "true"
Expand Down
2 changes: 2 additions & 0 deletions charts/daemonset/templates/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ kind: Secret
metadata:
namespace: {{ .Release.Namespace }}
name: {{ include "app.secret.fullname" . }}
labels:
{{ include "snowplow.labels" $ | nindent 4 }}
type: Opaque
data:
{{- range $k, $v := .Values.config.secrets }}
Expand Down
4 changes: 1 addition & 3 deletions charts/daemonset/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ kind: Service
metadata:
name: {{ include "app.fullname" . }}
labels:
{{- range $k, $v := .Values.service.labels }}
{{ $k }}: {{ $v }}
{{- end }}
{{ include "snowplow.labels" $ | nindent 4 }}
spec:
type: {{ .Values.service.type }}
selector:
Expand Down
3 changes: 3 additions & 0 deletions charts/daemonset/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ global:
# -- Cloud specific bindings (options: aws, gcp, azure)
cloud: ""

# global labels will be applied to all resources deployed by the chart
labels: {}

# -- Overrides the full-name given to the deployment resources (default: .Release.Name)
fullnameOverride: ""

Expand Down

0 comments on commit 58d8346

Please sign in to comment.