Skip to content

Commit 7df891a

Browse files
feat(vaultwarden): support CNPG as database
Signed-off-by: Sebastian Gaiser <sebastiangaiser@users.noreply.github.com>
1 parent 17f83a6 commit 7df891a

File tree

6 files changed

+53
-2
lines changed

6 files changed

+53
-2
lines changed

.github/workflows/lint-test.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ jobs:
5858
helm install postgres-operator postgres-operator-charts/postgres-operator
5959
if: steps.list-changed.outputs.changed == 'true'
6060

61+
- name: Install CNPG
62+
run: |
63+
helm install --atomic --namespace cnpg-system --create-namespace --repo https://cloudnative-pg.github.io/charts cnpg cloudnative-pg
64+
if: steps.list-changed.outputs.changed == 'true'
65+
6166
- name: Install prometheus-operator-crds
6267
run: |
6368
helm install --repo https://prometheus-community.github.io/helm-charts prometheus-operator-crds prometheus-operator-crds

charts/vaultwarden/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ icon: https://raw.githubusercontent.com/bitwarden/brand/master/icons/icon.svg
88
sources:
99
- https://github.com/dani-garcia/vaultwarden
1010
- https://github.com/sebastiangaiser/helm-charts/
11-
version: 0.11.11
11+
version: 0.12.0
1212
maintainers:
1313
- name: sebastiangaiser

charts/vaultwarden/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# vaultwarden
22

3-
![Version: 0.11.11](https://img.shields.io/badge/Version-0.11.11-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.33.2](https://img.shields.io/badge/AppVersion-1.33.2-informational?style=flat-square)
3+
![Version: 0.12.0](https://img.shields.io/badge/Version-0.12.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.33.2](https://img.shields.io/badge/AppVersion-1.33.2-informational?style=flat-square)
44

55
A Helm chart for deploying Vaultwarden to Kubernetes
66

@@ -22,6 +22,7 @@ A Helm chart for deploying Vaultwarden to Kubernetes
2222
| additionalVolumeMounts | list | `[]` | Additional volume mounts |
2323
| additionalVolumes | object | `{}` | Additional volumes |
2424
| affinity | object | `{}` | Affinities |
25+
| cnpg.enabled | bool | `false` | |
2526
| deploymentStrategy.type | string | `"Recreate"` | |
2627
| fullnameOverride | string | `""` | |
2728
| horizontalAutoscaling | object | `{"enabled":false,"maxReplicas":3,"minReplicas":1,"targetCPUUtilizationPercentage":75,"targetMemoryUtilizationPercentage":75}` | HPA configuration |
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
cnpg:
2+
enabled: true

charts/vaultwarden/templates/deployment.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,34 @@ spec:
4141
{{- end }}
4242
{{- if ( or .Values.initContainers .Values.zalandoPostgresql.enabled ) }}
4343
initContainers:
44+
{{- if .Values.cnpg.enabled }}
45+
- name: check-postgresql-ready
46+
image: "postgres:{{ .Values.cnpg.version }}"
47+
command: ['bash', '-c',
48+
'until pg_isready; do echo waiting for database be ready; sleep 2; done;']
49+
args: []
50+
env:
51+
- name: PGHOST
52+
valueFrom:
53+
secretKeyRef:
54+
name: "{{ include "vaultwarden.fullname" . }}-app"
55+
key: "hostname"
56+
- name: PGUSER
57+
valueFrom:
58+
secretKeyRef:
59+
name: "{{ include "vaultwarden.fullname" . }}-app"
60+
key: "username"
61+
- name: PGPASSWORD
62+
valueFrom:
63+
secretKeyRef:
64+
name: "{{ include "vaultwarden.fullname" . }}-app"
65+
key: "password"
66+
- name: PGDATABASE
67+
valueFrom:
68+
secretKeyRef:
69+
name: "{{ include "vaultwarden.fullname" . }}-app"
70+
key: "database"
71+
{{- end }}
4472
{{- if .Values.zalandoPostgresql.enabled }}
4573
- name: check-postgresql-ready
4674
image: "postgres:{{ .Values.zalandoPostgresql.version }}"
@@ -89,6 +117,13 @@ spec:
89117
name: {{ template "vaultwarden.fullname" . }}-admin-token
90118
key: admin-token
91119
{{- end }}
120+
{{- if .Values.cnpg.enabled }}
121+
- name: DATABASE_URL
122+
valueFrom:
123+
secretKeyRef:
124+
name: "{{ include "vaultwarden.fullname" . }}-app"
125+
key: "database-url"
126+
{{- end }}
92127
{{- if .Values.zalandoPostgresql.enabled }}
93128
- name: POSTGRES_HOST
94129
value: {{ .Values.zalandoPostgresql.teamId | default "acid" }}-{{ include "vaultwarden.fullname" . }}

charts/vaultwarden/values.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ tolerations: []
111111
# -- Affinities
112112
affinity: {}
113113

114+
## -- CNPG database configuration
115+
cnpg:
116+
enabled: false
117+
backup: {}
118+
version: "16"
119+
instances: "1"
120+
size: 1Gi
121+
114122
## -- Zalando PostgreSQL database configuration
115123
zalandoPostgresql:
116124
enabled: false

0 commit comments

Comments
 (0)