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

[PM-7621] Add better control on annotations and labels on deployments and pods #135

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion charts/self-host/templates/admin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ metadata:
{{ include "bitwarden.labels" . | indent 4 }}
{{- with .Values.component.admin.labels }}
{{ toYaml . | indent 4 }}
{{- end }}
annotations:
{{- include "bitwarden.annotations" . | indent 4 }}
{{- with .Values.component.admin.annotations }}
{{ toYaml . | indent 4 }}
{{- end }}
spec:
replicas: 1
Expand All @@ -23,7 +28,15 @@ spec:
labels:
app.kubernetes.io/component: admin
app: {{ template "bitwarden.admin" . }}
{{ include "bitwarden.labels" . | indent 8 }}
{{ include "bitwarden.podLabels" . | indent 8 }}
{{- with .Values.component.admin.podLabels }}
{{ toYaml . | indent 8 }}
{{- end }}
annotations:
{{- include "bitwarden.podAnnotations" . | indent 8 }}
{{- with .Values.component.admin.podAnnotations }}
{{ toYaml . | indent 8 }}
{{- end }}
spec:
{{- if .Values.component.admin.podServiceAccount }}
serviceAccount: {{ .Values.component.admin.podServiceAccount | quote }}
Expand Down
15 changes: 14 additions & 1 deletion charts/self-host/templates/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ metadata:
{{ include "bitwarden.labels" . | indent 4 }}
{{- with .Values.component.api.labels }}
{{ toYaml . | indent 4 }}
{{- end }}
annotations:
{{- include "bitwarden.annotations" . | indent 4 }}
{{- with .Values.component.api.annotations }}
{{ toYaml . | indent 4 }}
{{- end }}
spec:
replicas: 1
Expand All @@ -23,7 +28,15 @@ spec:
labels:
app: {{ template "bitwarden.api" . }}
app.kubernetes.io/component: api
{{ include "bitwarden.labels" . | indent 8 }}
{{ include "bitwarden.podLabels" . | indent 8 }}
{{- with .Values.component.api.podLabels }}
{{ toYaml . | indent 8 }}
{{- end }}
annotations:
{{- include "bitwarden.podAnnotations" . | indent 8 }}
{{- with .Values.component.api.podAnnotations }}
{{ toYaml . | indent 8 }}
{{- end }}
spec:
{{- if .Values.component.api.podServiceAccount }}
serviceAccount: {{ .Values.component.api.podServiceAccount | quote }}
Expand Down
15 changes: 14 additions & 1 deletion charts/self-host/templates/attachments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ metadata:
{{ include "bitwarden.labels" . | indent 4 }}
{{- with .Values.component.attachments.labels }}
{{ toYaml . | indent 4 }}
{{- end }}
annotations:
{{- include "bitwarden.annotations" . | indent 4 }}
{{- with .Values.component.attachments.annotations }}
{{ toYaml . | indent 4 }}
{{- end }}
spec:
replicas: 1
Expand All @@ -23,7 +28,15 @@ spec:
labels:
app: {{ template "bitwarden.attachments" . }}
app.kubernetes.io/component: attachments
{{ include "bitwarden.labels" . | indent 8 }}
{{ include "bitwarden.podLabels" . | indent 8 }}
{{- with .Values.component.attachments.podLabels }}
{{ toYaml . | indent 8 }}
{{- end }}
annotations:
{{- include "bitwarden.podAnnotations" . | indent 8 }}
{{- with .Values.component.attachments.podAnnotations }}
{{ toYaml . | indent 8 }}
{{- end }}
spec:
{{- if .Values.component.attachments.podServiceAccount }}
serviceAccount: {{ .Values.component.attachments.podServiceAccount | quote }}
Expand Down
15 changes: 14 additions & 1 deletion charts/self-host/templates/events.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ metadata:
{{ include "bitwarden.labels" . | indent 4 }}
{{- with .Values.component.events.labels }}
{{ toYaml . | indent 4 }}
{{- end }}
annotations:
{{- include "bitwarden.annotations" . | indent 4 }}
{{- with .Values.component.events.annotations }}
{{ toYaml . | indent 4 }}
{{- end }}
spec:
replicas: 1
Expand All @@ -23,7 +28,15 @@ spec:
labels:
app: {{ template "bitwarden.events" . }}
app.kubernetes.io/component: events
{{ include "bitwarden.labels" . | indent 8 }}
{{ include "bitwarden.podLabels" . | indent 8 }}
{{- with .Values.component.events.podLabels }}
{{ toYaml . | indent 8 }}
{{- end }}
annotations:
{{- include "bitwarden.podAnnotations" . | indent 8 }}
{{- with .Values.component.events.podAnnotations }}
{{ toYaml . | indent 8 }}
{{- end }}
spec:
{{- if .Values.component.events.podServiceAccount }}
serviceAccount: {{ .Values.component.events.podServiceAccount | quote }}
Expand Down
29 changes: 29 additions & 0 deletions charts/self-host/templates/helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,35 @@ helm.sh/chart: {{ template "bitwarden.chart" . }}
{{- end -}}
{{- end -}}

{{/*
Generate common pod labels
*/}}
{{- define "bitwarden.podLabels" -}}
{{ include "bitwarden.labels" . }}
{{- if .Values.general.podLabels }}
{{ toYaml .Values.general.podLabels }}
{{- end -}}
{{- end -}}

{{/*
Generate basic annotations
*/}}
{{- define "bitwarden.annotations" -}}
{{- if .Values.general.annotations }}
{{ toYaml .Values.general.annotations }}
{{- end -}}
{{- end -}}

{{/*
Generate common pod annotations
*/}}
{{- define "bitwarden.podAnnotations" -}}
{{ include "bitwarden.annotations" . }}
{{- if .Values.general.podAnnotations }}
{{ toYaml .Values.general.podAnnotations }}
{{- end -}}
{{- end -}}

{{/*
Generate basic labels
*/}}
Expand Down
15 changes: 14 additions & 1 deletion charts/self-host/templates/icons.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ metadata:
{{ include "bitwarden.labels" . | indent 4 }}
{{- with .Values.component.icons.labels }}
{{ toYaml . | indent 4 }}
{{- end }}
annotations:
{{- include "bitwarden.annotations" . | indent 4 }}
{{- with .Values.component.icons.annotations }}
{{ toYaml . | indent 4 }}
{{- end }}
spec:
replicas: 1
Expand All @@ -23,7 +28,15 @@ spec:
labels:
app: {{ template "bitwarden.icons" . }}
app.kubernetes.io/component: icons
{{ include "bitwarden.labels" . | indent 8 }}
{{ include "bitwarden.podLabels" . | indent 8 }}
{{- with .Values.component.icons.podLabels }}
{{ toYaml . | indent 8 }}
{{- end }}
annotations:
{{- include "bitwarden.podAnnotations" . | indent 8 }}
{{- with .Values.component.icons.podAnnotations }}
{{ toYaml . | indent 8 }}
{{- end }}
spec:
{{- if .Values.component.icons.podServiceAccount }}
serviceAccount: {{ .Values.component.icons.podServiceAccount | quote }}
Expand Down
15 changes: 14 additions & 1 deletion charts/self-host/templates/identity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ metadata:
{{ include "bitwarden.labels" . | indent 4 }}
{{- with .Values.component.identity.labels }}
{{ toYaml . | indent 4 }}
{{- end }}
annotations:
{{- include "bitwarden.annotations" . | indent 4 }}
{{- with .Values.component.identity.annotations }}
{{ toYaml . | indent 4 }}
{{- end }}
spec:
replicas: 1
Expand All @@ -23,7 +28,15 @@ spec:
labels:
app: {{ template "bitwarden.identity" . }}
app.kubernetes.io/component: identity
{{ include "bitwarden.labels" . | indent 8 }}
{{ include "bitwarden.podLabels" . | indent 8 }}
{{- with .Values.component.identity.podLabels }}
{{ toYaml . | indent 8 }}
{{- end }}
annotations:
{{- include "bitwarden.podAnnotations" . | indent 8 }}
{{- with .Values.component.identity.podAnnotations }}
{{ toYaml . | indent 8 }}
{{- end }}
spec:
{{- if .Values.component.identity.podServiceAccount }}
serviceAccount: {{ .Values.component.identity.podServiceAccount | quote }}
Expand Down
2 changes: 2 additions & 0 deletions charts/self-host/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ metadata:
{{- with .Values.general.ingress.labels }}
{{ toYaml . | indent 4 }}
{{- end }}
annotations:
{{- include "bitwarden.annotations" . | indent 4 }}
Comment on lines +21 to +22
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be moved up near line 8 where the current annotations key is defined.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this may have been missed. The ingress.yaml file has two annotations keys. Line 21 should be deleted and Line 22 should be moved above line 12.

spec:
ingressClassName: {{.Values.general.ingress.className}}
rules:
Expand Down
16 changes: 16 additions & 0 deletions charts/self-host/templates/mssql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ metadata:
{{ include "bitwarden.labels" . | indent 4 }}
{{- with .Values.database.labels }}
{{ toYaml . | indent 4 }}
{{- end }}
annotations:
{{- include "bitwarden.annotations" . | indent 4 }}
{{- with .Values.database.annotations }}
{{ toYaml . | indent 4 }}
{{- end }}
spec:
serviceName: {{ template "bitwarden.mssql" . }}
Expand All @@ -28,6 +33,17 @@ spec:
{{ include "bitwarden.labels" . | indent 8 }}
{{- with .Values.database.labels }}
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.database.podLabels }}
{{ toYaml . | indent 8 }}
{{- end }}
annotations:
{{ include "bitwarden.annotations" . | indent 8 }}
{{- with .Values.database.annotations }}
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.database.podAnnotations }}
{{ toYaml . | indent 8 }}
{{- end }}
spec:
{{- if .Values.database.podServiceAccount }}
Expand Down
15 changes: 14 additions & 1 deletion charts/self-host/templates/notifications.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ metadata:
{{ include "bitwarden.labels" . | indent 4 }}
{{- with .Values.component.notifications.labels }}
{{ toYaml . | indent 4 }}
{{- end }}
annotations:
{{- include "bitwarden.annotations" . | indent 4 }}
{{- with .Values.component.notifications.annotations }}
{{ toYaml . | indent 4 }}
{{- end }}
spec:
replicas: 1
Expand All @@ -23,7 +28,15 @@ spec:
labels:
app: {{ template "bitwarden.notifications" . }}
app.kubernetes.io/component: notifications
{{ include "bitwarden.labels" . | indent 8 }}
{{ include "bitwarden.podLabels" . | indent 8 }}
{{- with .Values.component.notifications.podLabels }}
{{ toYaml . | indent 8 }}
{{- end }}
annotations:
{{- include "bitwarden.podAnnotations" . | indent 8 }}
{{- with .Values.component.notifications.podAnnotations }}
{{ toYaml . | indent 8 }}
{{- end }}
spec:
{{- if .Values.component.notifications.podServiceAccount }}
serviceAccount: {{ .Values.component.notifications.podServiceAccount | quote }}
Expand Down
17 changes: 17 additions & 0 deletions charts/self-host/templates/post-delete-hook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,33 @@ metadata:
name: "{{ .Release.Name }}-cleanup"
labels:
app.kubernetes.io/component: post-delete-hook
{{ include "bitwarden.labels" . | indent 4 }}
{{- with .Values.job.cleanup.labels }}
{{ toYaml . | indent 4 }}
{{- end }}
annotations:
"helm.sh/hook": post-delete
"helm.sh/hook-weight": "0"
"helm.sh/hook-delete-policy": hook-succeeded,hook-failed,before-hook-creation
{{- include "bitwarden.annotations" . | indent 4 }}
{{- with .Values.job.cleanup.annotations }}
{{ toYaml . | indent 4 }}
{{- end }}
spec:
template:
metadata:
name: "{{ .Release.Name }}-cleanup"
labels:
app.kubernetes.io/component: post-delete-hook
{{ include "bitwarden.podLabels" . | indent 8 }}
{{- with .Values.job.cleanup.podLabels }}
{{ toYaml . | indent 8 }}
{{- end }}
annotations:
{{- include "bitwarden.podAnnotations" . | indent 8 }}
{{- with .Values.job.cleanup.podAnnotations }}
{{ toYaml . | indent 8 }}
{{- end }}
spec:
{{- if .Values.serviceAccount.name }}
serviceAccountName: "{{ .Values.serviceAccount.name }}"
Expand Down
17 changes: 17 additions & 0 deletions charts/self-host/templates/post-install-db-migrator-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,33 @@ metadata:
name: "{{ .Release.Name }}-migrator"
labels:
app.kubernetes.io/component: post-install-db-migrator-job
{{ include "bitwarden.labels" . | indent 4 }}
{{- with .Values.job.db.labels }}
{{ toYaml . | indent 4 }}
{{- end }}
annotations:
"helm.sh/hook": post-install,post-upgrade
"helm.sh/hook-weight": "0"
"helm.sh/hook-delete-policy": hook-succeeded,hook-failed,before-hook-creation
{{- include "bitwarden.annotations" . | indent 4 }}
{{- with .Values.job.db.annotations }}
{{ toYaml . | indent 4 }}
{{- end }}
spec:
template:
metadata:
name: "{{ .Release.Name }}-migrator"
labels:
app.kubernetes.io/component: post-install-db-migrator-job
{{ include "bitwarden.podLabels" . | indent 8 }}
{{- with .Values.job.db.podLabels }}
{{ toYaml . | indent 8 }}
{{- end }}
annotations:
{{- include "bitwarden.podAnnotations" . | indent 8 }}
{{- with .Values.job.db.podAnnotations }}
{{ toYaml . | indent 8 }}
{{- end }}
spec:
{{- if .Values.serviceAccount.name }}
serviceAccountName: "{{ .Values.serviceAccount.name }}"
Expand Down
1 change: 1 addition & 0 deletions charts/self-host/templates/post-install-raw-manifests.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{- range .Values.rawManifests.postInstall }}
{{- $manifest := include "bitwarden.labels" $ | fromYaml | dict "labels" | dict "metadata" | mergeOverwrite . }}
{{- $manifest := include "bitwarden.annotations" $ | fromYaml | dict "annotations" | dict "metadata" | mergeOverwrite . }}
{{- $manifest := include "bitwarden.rawPostInstallAnnotations" $ | fromYaml | dict "annotations" | mergeOverwrite $manifest }}
{{- toYaml $manifest }}
---
Expand Down
23 changes: 20 additions & 3 deletions charts/self-host/templates/pre-install-db-migrator-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,37 @@ metadata:
name: "{{ .Release.Name }}-db-pre-upgrade"
labels:
app.kubernetes.io/component: pre-install-db-migrator-job
{{ include "bitwarden.labels" . | indent 4 }}
{{- with .Values.job.db.labels }}
{{ toYaml . | indent 4 }}
{{- end }}
annotations:
{{- if .Values.database.enabled }}
{{- if .Values.database.enabled }}
"helm.sh/hook": pre-upgrade
{{- else }}
{{- else }}
"helm.sh/hook": pre-install,pre-upgrade
{{- end }}
{{- end }}
"helm.sh/hook-weight": "4"
"helm.sh/hook-delete-policy": hook-succeeded,hook-failed,before-hook-creation
{{- include "bitwarden.annotations" . | indent 4 }}
{{- with .Values.job.db.annotations }}
{{ toYaml . | indent 4 }}
{{- end }}
spec:
template:
metadata:
name: "{{ .Release.Name }}-db-pre-upgrade"
labels:
app.kubernetes.io/component: pre-install-db-migrator-job
{{ include "bitwarden.podLabels" . | indent 8 }}
{{- with .Values.job.db.podLabels }}
{{ toYaml . | indent 8 }}
{{- end }}
annotations:
{{- include "bitwarden.podAnnotations" . | indent 8 }}
{{- with .Values.job.db.podAnnotations }}
{{ toYaml . | indent 8 }}
{{- end }}
spec:
{{- if .Values.serviceAccount.name }}
serviceAccountName: {{ .Values.serviceAccount.name | quote }}
Expand Down
Loading
Loading