Skip to content

Commit 79be751

Browse files
sebastiangaiserSebastian Gaiser
authored andcommitted
feat(vaultwarden): support CNPG as database
Signed-off-by: Sebastian Gaiser <sebastiangaiser@users.noreply.github.com> Signed-off-by: Sebastian Gaiser <sebastian.gaiser@hetzner-cloud.de>
1 parent 98302c3 commit 79be751

File tree

6 files changed

+56
-3
lines changed

6 files changed

+56
-3
lines changed

.github/linters/.markdown-lint.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
MD013:
2+
line_length: 600
3+
MD060:
4+
table-column-style: tight
5+
aligned_delimiter: true

.github/workflows/lint-test.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ jobs:
7171
helm install prometheus-operator-crds oci://ghcr.io/prometheus-community/charts/prometheus-operator-crds
7272
if: steps.list-changed.outputs.changed == 'true'
7373

74+
- name: Install CNPG
75+
run: |
76+
helm install --namespace cnpg-system --create-namespace --repo https://cloudnative-pg.github.io/charts cnpg cloudnative-pg
77+
if: steps.list-changed.outputs.changed == 'true'
78+
7479
- name: Run chart-testing (install)
7580
run: ct install --config .github/linters/ct.yaml
7681

charts/vaultwarden/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ 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.13.1
11+
version: 0.14.0

charts/vaultwarden/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ A Helm chart for deploying Vaultwarden to Kubernetes
1414
| additionalVolumeMounts | list | `[]` | Additional volume mounts |
1515
| additionalVolumes | object | `{}` | Additional volumes |
1616
| affinity | object | `{}` | Affinities |
17+
| cnpg.backup | object | `{}` | |
1718
| cnpg.enabled | bool | `false` | |
19+
| cnpg.instances | string | `"1"` | |
20+
| cnpg.size | string | `"1Gi"` | |
21+
| cnpg.version | string | `"18"` | |
1822
| deploymentStrategy.type | string | `"Recreate"` | |
1923
| fullnameOverride | string | `""` | |
2024
| horizontalAutoscaling | object | `{"enabled":false,"maxReplicas":3,"minReplicas":1,"targetCPUUtilizationPercentage":75,"targetMemoryUtilizationPercentage":75}` | HPA configuration |
@@ -52,7 +56,7 @@ A Helm chart for deploying Vaultwarden to Kubernetes
5256
| zalandoPostgresql.resources.requests.cpu | string | `"250m"` | |
5357
| zalandoPostgresql.resources.requests.memory | string | `"250Mi"` | |
5458
| zalandoPostgresql.size | string | `"1Gi"` | |
55-
| zalandoPostgresql.version | string | `"16"` | |
59+
| zalandoPostgresql.version | string | `"18"` | |
5660

5761
## Upgrading
5862

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 }}"
@@ -100,6 +128,13 @@ spec:
100128
name: {{ template "vaultwarden.fullname" . }}-admin-token
101129
key: admin-token
102130
{{- end }}
131+
{{- if .Values.cnpg.enabled }}
132+
- name: DATABASE_URL
133+
valueFrom:
134+
secretKeyRef:
135+
name: "{{ include "vaultwarden.fullname" . }}-app"
136+
key: "database-url"
137+
{{- end }}
103138
{{- if .Values.zalandoPostgresql.enabled }}
104139
- name: POSTGRES_HOST
105140
value: {{ .Values.zalandoPostgresql.teamId | default "acid" }}-{{ include "vaultwarden.fullname" . }}

charts/vaultwarden/values.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,15 @@ affinity: {}
117117
## -- CNPG database configuration
118118
cnpg:
119119
enabled: false
120+
backup: {}
121+
version: "18"
122+
instances: "1"
123+
size: 1Gi
120124

121125
## -- Zalando PostgreSQL database configuration
122126
zalandoPostgresql:
123127
enabled: false
124-
version: "16"
128+
version: "18"
125129
instances: 1
126130
size: 1Gi
127131
resources:

0 commit comments

Comments
 (0)