Skip to content
2 changes: 2 additions & 0 deletions charts/self-host/templates/admin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ metadata:
labels:
app.kubernetes.io/component: admin
app: {{ template "bitwarden.admin" . }}

{{ include "bitwarden.labels" . | indent 4 }}
{{- with .Values.component.admin.labels }}
{{ toYaml . | indent 4 }}
Expand All @@ -25,6 +26,7 @@ spec:
app: {{ template "bitwarden.admin" . }}
{{ include "bitwarden.labels" . | indent 8 }}
spec:
{{ include "bitwarden.podCoLocation.affinity" . | indent 6 }}
{{- if .Values.component.admin.podServiceAccount }}
serviceAccount: {{ .Values.component.admin.podServiceAccount | quote }}
serviceAccountName: {{ .Values.component.admin.podServiceAccount | quote }}
Expand Down
2 changes: 2 additions & 0 deletions charts/self-host/templates/attachments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ metadata:
{{ toYaml . | indent 4 }}
{{- end }}
spec:

replicas: 1
strategy:
type: {{ .Values.component.attachments.deploymentStrategy | quote }}
Expand All @@ -25,6 +26,7 @@ spec:
app.kubernetes.io/component: attachments
{{ include "bitwarden.labels" . | indent 8 }}
spec:
{{ include "bitwarden.podCoLocation.affinity" . | indent 6 }}
{{- if .Values.component.attachments.podServiceAccount }}
serviceAccount: {{ .Values.component.attachments.podServiceAccount | quote }}
serviceAccountName: {{ .Values.component.attachments.podServiceAccount | quote }}
Expand Down
2 changes: 2 additions & 0 deletions charts/self-host/templates/events.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ metadata:
{{ toYaml . | indent 4 }}
{{- end }}
spec:

replicas: 1
strategy:
type: {{ .Values.component.events.deploymentStrategy | quote }}
Expand All @@ -25,6 +26,7 @@ spec:
app.kubernetes.io/component: events
{{ include "bitwarden.labels" . | indent 8 }}
spec:
{{ include "bitwarden.podCoLocation.affinity" . | indent 6 }}
{{- if .Values.component.events.podServiceAccount }}
serviceAccount: {{ .Values.component.events.podServiceAccount | quote }}
serviceAccountName: {{ .Values.component.events.podServiceAccount | quote }}
Expand Down
19 changes: 19 additions & 0 deletions charts/self-host/templates/helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ app.kubernetes.io/name: {{ template "bitwarden.name" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
helm.sh/chart: {{ template "bitwarden.chart" . }}
{{- if eq .Values.general.volumeAccessMode "ReadWriteOnce" }}
app.kubernetes.io/storage: "ReadWriteOnce"
{{- end -}}
{{- if .Values.general.labels }}
{{ toYaml .Values.general.labels }}
{{- end -}}
Expand Down Expand Up @@ -225,6 +228,22 @@ Name of SCIM components
{{ template "bitwarden.fullname" . }}-scim
{{- end -}}

{{- define "bitwarden.podCoLocation.affinity" -}}
{{- if eq .Values.general.volumeAccessMode "ReadWriteOnce" }}
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app.kubernetes.io/storage
operator: In
values:
- ReadWriteOnce
topologyKey: "kubernetes.io/hostname"
{{- end -}}
{{- end -}}


{{/*
Name of the keys secret
*/}}
Expand Down
1 change: 1 addition & 0 deletions charts/self-host/templates/icons.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ spec:
app.kubernetes.io/component: icons
{{ include "bitwarden.labels" . | indent 8 }}
spec:
{{ include "bitwarden.podCoLocation.affinity" . | indent 6 }}
{{- if .Values.component.icons.podServiceAccount }}
serviceAccount: {{ .Values.component.icons.podServiceAccount | quote }}
serviceAccountName: {{ .Values.component.icons.podServiceAccount | quote }}
Expand Down
1 change: 1 addition & 0 deletions charts/self-host/templates/identity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ spec:
app.kubernetes.io/component: identity
{{ include "bitwarden.labels" . | indent 8 }}
spec:
{{ include "bitwarden.podCoLocation.affinity" . | indent 6 }}
{{- if .Values.component.identity.podServiceAccount }}
serviceAccount: {{ .Values.component.identity.podServiceAccount | quote }}
serviceAccountName: {{ .Values.component.identity.podServiceAccount | quote }}
Expand Down
1 change: 1 addition & 0 deletions charts/self-host/templates/notifications.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ spec:
app.kubernetes.io/component: notifications
{{ include "bitwarden.labels" . | indent 8 }}
spec:
{{ include "bitwarden.podCoLocation.affinity" . | indent 6 }}
{{- if .Values.component.notifications.podServiceAccount }}
serviceAccount: {{ .Values.component.notifications.podServiceAccount | quote }}
serviceAccountName: {{ .Values.component.notifications.podServiceAccount | quote }}
Expand Down
12 changes: 12 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 @@ -16,6 +16,18 @@ spec:
labels:
app.kubernetes.io/component: post-install-db-migrator-job
spec:
{{- if and (.Values.database.enabled) ( eq .Values.general.volumeAccessMode "ReadWriteOnce") }}
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- {{ template "bitwarden.mssql" . }}
topologyKey: "kubernetes.io/hostname"
{{- end }}
{{- if .Values.serviceAccount.name }}
serviceAccountName: "{{ .Values.serviceAccount.name }}"
{{- end }}
Expand Down
12 changes: 12 additions & 0 deletions charts/self-host/templates/pre-install-db-migrator-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ spec:
labels:
app.kubernetes.io/component: pre-install-db-migrator-job
spec:
{{- if and (.Values.database.enabled) (eq .Values.general.volumeAccessMode "ReadWriteOnce") }}
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- {{ template "bitwarden.mssql" . }}
topologyKey: "kubernetes.io/hostname"
{{- end }}
{{- if .Values.serviceAccount.name }}
serviceAccountName: {{ .Values.serviceAccount.name | quote }}
{{- end }}
Expand Down
1 change: 1 addition & 0 deletions charts/self-host/templates/scim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ spec:
app.kubernetes.io/component: scim
{{ include "bitwarden.labels" . | indent 8 }}
spec:
{{ include "bitwarden.podCoLocation.affinity" . | indent 6 }}
{{- if .Values.component.scim.podServiceAccount }}
serviceAccount: {{ .Values.component.scim.podServiceAccount | quote }}
serviceAccountName: {{ .Values.component.scim.podServiceAccount | quote }}
Expand Down
1 change: 1 addition & 0 deletions charts/self-host/templates/sso.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ spec:
app.kubernetes.io/component: sso
{{ include "bitwarden.labels" . | indent 8 }}
spec:
{{ include "bitwarden.podCoLocation.affinity" . | indent 6 }}
{{- if .Values.component.sso.podServiceAccount }}
serviceAccount: {{ .Values.component.sso.podServiceAccount | quote }}
serviceAccountName: {{ .Values.component.sso.podServiceAccount | quote }}
Expand Down
Loading