Skip to content

Commit

Permalink
charts/cron-job add global labels (closes #182)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianarsenault committed Jul 31, 2024
1 parent 5985977 commit f7bb8e6
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/cron-job/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: cron-job
description: A Helm Chart to deploy an arbitrary container as a cron job.
version: 0.6.0
version: 0.7.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
1 change: 1 addition & 0 deletions charts/cron-job/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ helm delete cron-job
| Key | Type | Default | Description |
|-----|------|---------|-------------|
| global.cloud | string | `""` | Cloud specific bindings (options: aws, gcp, azure) |
| global.labels | object | `{}` | Global labels deployed to all resources deployed by the chart |
| fullnameOverride | string | `""` | Overrides the full-name given to the deployment resources (default: .Release.Name) |
| schedule | string | `"*/1 * * * *"` | |
| concurrencyPolicy | string | `"Forbid"` | |
Expand Down
21 changes: 21 additions & 0 deletions charts/cron-job/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 "cron.job.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 "cron.job.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/cron-job/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/cron-job/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "app.fullname" . }}
labels:
{{ include "snowplow.labels" $ | nindent 4 }}
spec:
schedule: "{{ .Values.schedule }}"
concurrencyPolicy: "{{ .Values.concurrencyPolicy }}"
Expand All @@ -13,6 +15,7 @@ spec:
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/cron-job/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
3 changes: 3 additions & 0 deletions charts/cron-job/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 f7bb8e6

Please sign in to comment.