Skip to content

Commit

Permalink
Add proper handling for common and pod specific labels and annotation…
Browse files Browse the repository at this point in the history
…s. (#280)

* Add proper handling for common and pod specific labels and annotations.
* Improved repo readme page, added artifacthub badge.
  • Loading branch information
mgruner authored Jul 24, 2024
1 parent 6e7a1af commit 849fbfd
Show file tree
Hide file tree
Showing 18 changed files with 173 additions and 30 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# Zammad Helm Chart

[![Artifact Hub](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/zammad)](https://artifacthub.io/packages/helm/zammad/zammad)
[![Release downloads](https://img.shields.io/github/downloads/zammad/zammad-helm/total.svg)](https://github.com/zammad/zammad-helm/releases)
[![Release Charts](https://github.com/zammad/zammad-helm/workflows/Release%20Charts/badge.svg)](https://github.com/zammad/zammad-helm/commits/master)

A [Helm](https://helm.sh) chart to install [Zammad](https://zammad.org) on [Kubernetes](https://kubernetes.io)

Please see [zammad/README.md](zammad/README.md) for detailed information & instructions.

## Repository Info

[![Releases downloads](https://img.shields.io/github/downloads/zammad/zammad-helm/total.svg)](https://github.com/zammad/zammad-helm/releases)
[![Release Charts](https://github.com/zammad/zammad-helm/workflows/Release%20Charts/badge.svg)](https://github.com/zammad/zammad-helm/commits/master)

## Sources

* [Helm chart sources](https://github.com/zammad/zammad-helm)
Expand Down
4 changes: 2 additions & 2 deletions zammad/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: zammad
version: 12.2.3
appVersion: 6.3.1-78
version: 12.3.0
appVersion: 6.3.1-91
description: Zammad is a web based open source helpdesk/customer support system with many features to manage customer communication via several channels like telephone, facebook, twitter, chat and e-mails.
home: https://zammad.org
icon: https://raw.githubusercontent.com/zammad/zammad-documentation/main/images/zammad_logo_600x520.png
Expand Down
37 changes: 37 additions & 0 deletions zammad/ci/full-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,40 @@ zammadConfig:
- name: custom-volume
mountPath: /opt/zammad/lib/tasks/helm
readOnly: true
nginx:
podLabels:
my-nginx-pod-label: my-nginx-pod-label-value
podAnnotations:
my-nginx-pod-annotation: my-nginx-pod-annotation-value
railsserver:
podLabels:
my-railsserver-pod-label: my-railsserver-pod-label-value
podAnnotations:
my-railsserver-pod-annotation: my-railsserver-pod-annotation-value
scheduler:
podLabels:
my-scheduler-pod-label: my-scheduler-pod-label-value
podAnnotations:
my-scheduler-pod-annotation: my-scheduler-pod-annotation-value
websocket:
podLabels:
my-websocket-pod-label: my-websocket-pod-label-value
podAnnotations:
my-websocket-pod-annotation: my-websocket-pod-annotation-value
initJob:
podLabels:
my-initJob-pod-label: my-initJob-pod-label-value
podAnnotations:
my-initJob-pod-annotation: my-initJob-pod-annotation-value

commonLabels:
my-common-label: my-common-label-value

commonAnnotations:
my-common-annotation: my-common-annotation-value

podLabels:
my-pod-label: my-pod-label-value

podAnnotations:
my-pod-annotation: my-pod-annotation-value
32 changes: 32 additions & 0 deletions zammad/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ helm.sh/chart: {{ include "zammad.chart" . }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.commonLabels }}
{{ toYaml . }}
{{- end }}
{{- end -}}

{{/*
Pod labels
*/}}
{{- define "zammad.podLabels" -}}
{{ include "zammad.labels" . }}
{{- with .Values.podLabels }}
{{ toYaml . }}
{{- end }}
{{- end -}}

{{/*
Expand All @@ -51,6 +64,25 @@ app.kubernetes.io/name: {{ include "zammad.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}

{{/*
Common annotations
*/}}
{{- define "zammad.annotations" -}}
{{- with .Values.commonAnnotations }}
{{ toYaml . }}
{{- end }}
{{- end -}}

{{/*
Pod annotations
*/}}
{{- define "zammad.podAnnotations" -}}
{{ include "zammad.annotations" . }}
{{- with .Values.podAnnotations }}
{{ toYaml . }}
{{- end }}
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
Expand Down
2 changes: 2 additions & 0 deletions zammad/templates/configmap-init.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ metadata:
name: {{ include "zammad.fullname" . }}-init
labels:
{{- include "zammad.labels" . | nindent 4 }}
annotations:
{{- include "zammad.annotations" . | nindent 4 }}
data:
postgresql-init: |-
#!/bin/bash
Expand Down
2 changes: 2 additions & 0 deletions zammad/templates/configmap-nginx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ metadata:
name: {{ include "zammad.fullname" . }}-nginx
labels:
{{- include "zammad.labels" . | nindent 4 }}
annotations:
{{- include "zammad.annotations" . | nindent 4 }}
data:
default: |-
#
Expand Down
14 changes: 10 additions & 4 deletions zammad/templates/deployment-nginx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,26 @@ metadata:
labels:
{{- include "zammad.labels" . | nindent 4 }}
app.kubernetes.io/component: zammad-nginx
annotations:
{{- include "zammad.annotations" . | nindent 4 }}
spec:
replicas: {{ .Values.zammadConfig.nginx.replicas }}
selector:
matchLabels:
{{- include "zammad.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "zammad.podAnnotations" . | nindent 8 }}
{{- with .Values.zammadConfig.nginx.podAnnotations }}
{{- toYaml . | nindent 8}}
{{- end }}
labels:
{{- include "zammad.labels" . | nindent 8 }}
{{- include "zammad.podLabels" . | nindent 8 }}
app.kubernetes.io/component: zammad-nginx
{{- with .Values.zammadConfig.nginx.podLabels }}
{{- toYaml . | nindent 8}}
{{- end }}
spec:
{{- include "zammad.podSpec.deployment" . | nindent 6 }}
containers:
Expand Down
14 changes: 10 additions & 4 deletions zammad/templates/deployment-railsserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,26 @@ metadata:
labels:
{{- include "zammad.labels" . | nindent 4 }}
app.kubernetes.io/component: zammad-railsserver
annotations:
{{- include "zammad.annotations" . | nindent 4 }}
spec:
replicas: {{ .Values.zammadConfig.railsserver.replicas }}
selector:
matchLabels:
{{- include "zammad.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "zammad.podAnnotations" . | nindent 8 }}
{{- with .Values.zammadConfig.railsserver.podAnnotations }}
{{- toYaml . | nindent 8}}
{{- end }}
labels:
{{- include "zammad.labels" . | nindent 8 }}
{{- include "zammad.podLabels" . | nindent 8 }}
app.kubernetes.io/component: zammad-railsserver
{{- with .Values.zammadConfig.railsserver.podLabels }}
{{- toYaml . | nindent 8}}
{{- end }}
spec:
{{- include "zammad.podSpec.deployment" . | nindent 6 }}
containers:
Expand Down
14 changes: 10 additions & 4 deletions zammad/templates/deployment-scheduler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,26 @@ metadata:
labels:
{{- include "zammad.labels" . | nindent 4 }}
app.kubernetes.io/component: zammad-scheduler
annotations:
{{- include "zammad.annotations" . | nindent 4 }}
spec:
replicas: 1 # Not scalable, may only run once per cluster.
selector:
matchLabels:
{{- include "zammad.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "zammad.podAnnotations" . | nindent 8 }}
{{- with .Values.zammadConfig.scheduler.podAnnotations }}
{{- toYaml . | nindent 8}}
{{- end }}
labels:
{{- include "zammad.labels" . | nindent 8 }}
{{- include "zammad.podLabels" . | nindent 8 }}
app.kubernetes.io/component: zammad-scheduler
{{- with .Values.zammadConfig.scheduler.podLabels }}
{{- toYaml . | nindent 8}}
{{- end }}
spec:
{{- include "zammad.podSpec.deployment" . | nindent 6 }}
containers:
Expand Down
14 changes: 10 additions & 4 deletions zammad/templates/deployment-websocket.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,26 @@ metadata:
labels:
{{- include "zammad.labels" . | nindent 4 }}
app.kubernetes.io/component: zammad-websocket
annotations:
{{- include "zammad.annotations" . | nindent 4 }}
spec:
replicas: 1 # Not scalable, may only run once per cluster.
selector:
matchLabels:
{{- include "zammad.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "zammad.podAnnotations" . | nindent 8 }}
{{- with .Values.zammadConfig.websocket.podAnnotations }}
{{- toYaml . | nindent 8}}
{{- end }}
labels:
{{- include "zammad.labels" . | nindent 8 }}
{{- include "zammad.podLabels" . | nindent 8 }}
app.kubernetes.io/component: zammad-websocket
{{- with .Values.zammadConfig.websocket.podLabels }}
{{- toYaml . | nindent 8}}
{{- end }}
spec:
{{- include "zammad.podSpec.deployment" . | nindent 6 }}
containers:
Expand Down
3 changes: 2 additions & 1 deletion zammad/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ metadata:
name: {{ $fullName }}
labels:
{{- include "zammad.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- include "zammad.annotations" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
Expand Down
15 changes: 10 additions & 5 deletions zammad/templates/job-init.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,26 @@ metadata:
labels:
{{- include "zammad.labels" . | nindent 4 }}
app.kubernetes.io/component: zammad-init
{{- with .Values.zammadConfig.initJob.annotations }}
annotations:
{{- include "zammad.annotations" . | nindent 4 }}
{{- with .Values.zammadConfig.initJob.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
ttlSecondsAfterFinished: 300
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "zammad.podAnnotations" . | nindent 8 }}
{{- with .Values.zammadConfig.initJob.podAnnotations }}
{{- toYaml . | nindent 8}}
{{- end }}
labels:
{{- include "zammad.labels" . | nindent 8 }}
{{- include "zammad.podLabels" . | nindent 8 }}
app.kubernetes.io/component: zammad-init
{{- with .Values.zammadConfig.initJob.podLabels }}
{{- toYaml . | nindent 8}}
{{- end }}
spec:
{{- include "zammad.podSpec" . | nindent 6 }}
restartPolicy: OnFailure
Expand Down
8 changes: 8 additions & 0 deletions zammad/templates/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ metadata:
name: {{ include "zammad.autowizardSecretName" . }}
labels:
{{- include "zammad.labels" . | nindent 4 }}
annotations:
{{- include "zammad.annotations" . | nindent 4 }}
type: Opaque
data:
{{ .Values.secrets.autowizard.secretKey }}: {{ .Values.autoWizard.config | b64enc | quote }}
Expand All @@ -17,6 +19,8 @@ metadata:
name: {{ include "zammad.elasticsearchSecretName" . }}
labels:
{{- include "zammad.labels" . | nindent 4 }}
annotations:
{{- include "zammad.annotations" . | nindent 4 }}
type: Opaque
data:
{{ .Values.secrets.elasticsearch.secretKey }}: {{ .Values.zammadConfig.elasticsearch.pass | b64enc | quote }}
Expand All @@ -29,6 +33,8 @@ metadata:
name: {{ include "zammad.postgresqlSecretName" . }}
labels:
{{- include "zammad.labels" . | nindent 4 }}
annotations:
{{- include "zammad.annotations" . | nindent 4 }}
type: Opaque
data:
{{ .Values.secrets.postgresql.secretKey }}: {{ .Values.zammadConfig.postgresql.pass | b64enc | quote }}
Expand All @@ -41,6 +47,8 @@ metadata:
name: {{ include "zammad.redisSecretName" . }}
labels:
{{- include "zammad.labels" . | nindent 4 }}
annotations:
{{- include "zammad.annotations" . | nindent 4 }}
type: Opaque
data:
{{ .Values.secrets.redis.secretKey }}: {{ .Values.zammadConfig.redis.pass | b64enc | quote }}
Expand Down
2 changes: 2 additions & 0 deletions zammad/templates/service-nginx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ metadata:
name: {{ include "zammad.fullname" . }}-nginx
labels:
{{- include "zammad.labels" . | nindent 4 }}
annotations:
{{- include "zammad.annotations" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
Expand Down
2 changes: 2 additions & 0 deletions zammad/templates/service-railsserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ metadata:
name: {{ include "zammad.fullname" . }}-railsserver
labels:
{{- include "zammad.labels" . | nindent 4 }}
annotations:
{{- include "zammad.annotations" . | nindent 4 }}
spec:
ports:
- port: 3000
Expand Down
2 changes: 2 additions & 0 deletions zammad/templates/service-websocket.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ metadata:
name: {{ include "zammad.fullname" . }}-websocket
labels:
{{- include "zammad.labels" . | nindent 4 }}
annotations:
{{- include "zammad.annotations" . | nindent 4 }}
spec:
ports:
- port: 6042
Expand Down
3 changes: 2 additions & 1 deletion zammad/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ metadata:
name: {{ include "zammad.serviceAccountName" . }}
labels:
{{- include "zammad.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- include "zammad.annotations" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
Loading

0 comments on commit 849fbfd

Please sign in to comment.