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

Feat: co location on readwrite once storage #69

Open
wants to merge 9 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
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 }}"
serviceAccountName: "{{ .Values.component.admin.podServiceAccount }}"
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 }}"
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 }}"
serviceAccountName: "{{ .Values.component.attachments.podServiceAccount }}"
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 }}"
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 }}"
serviceAccountName: "{{ .Values.component.events.podServiceAccount }}"
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 }}"
serviceAccountName: "{{ .Values.component.icons.podServiceAccount }}"
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 }}"
serviceAccountName: "{{ .Values.component.identity.podServiceAccount }}"
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 }}"
serviceAccountName: "{{ .Values.component.notifications.podServiceAccount }}"
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 }}"
{{- 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 }}"
serviceAccountName: "{{ .Values.component.scim.podServiceAccount }}"
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 }}"
serviceAccountName: "{{ .Values.component.sso.podServiceAccount }}"
Expand Down