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

WIP: feat: allow passing postgresql username and password from operator secret #100

Open
wants to merge 1 commit 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: 1 addition & 1 deletion charts/vaultwarden/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ maintainers:
- name: guerzon
email: [email protected]
url: https://github.com/guerzon
version: 0.23.1
version: 0.24.3
kubeVersion: ">=1.12.0-0"
28 changes: 15 additions & 13 deletions charts/vaultwarden/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,19 +321,21 @@ helm -n $NAMESPACE uninstall $RELEASE_NAME

### Database settings

| Name | Description | Value |
| ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | --------- |
| `database.type` | Database type, either mysql or postgresql | `default` |
| `database.host` | Database hostname or IP address | `""` |
| `database.port` | Database port | `""` |
| `database.username` | Database username | `""` |
| `database.password` | Database password | `""` |
| `database.dbName` | Database name | `""` |
| `database.uriOverride` | Manually specify the DB connection string | `""` |
| `database.existingSecret` | Name of an existing secret containing the database URI | `""` |
| `database.existingSecretKey` | Key in the existing secret | `""` |
| `database.connectionRetries` | Number of times to retry the database connection during startup, with 1 second delay between each retry, set to 0 to retry indefinitely. | `15` |
| `database.maxConnections` | Define the size of the connection pool used for connecting to the database. | `10` |
| Name | Description | Value |
| ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------- | ---------- |
| `database.type` | Database type, either mysql or postgresql | `default` |
| `database.host` | Database hostname or IP address | `""` |
| `database.port` | Database port | `""` |
| `database.username` | Database username | `""` |
| `database.password` | Database password | `""` |
| `database.dbName` | Database name | `""` |
| `database.uriOverride` | Manually specify the DB connection string | `""` |
| `database.existingSecret` | Name of an existing secret containing either a single key with the database uri, or a separate key for username and password | `""` |
| `database.existingSecretKey` | Key in the existing secret | `""` |
| `database.existingSecretUserKey` | Key in the existing secret | `username` |
| `database.existingSecretPasswordKey` | Key in the existing secret | `password` |
| `database.connectionRetries` | Number of times to retry the database connection during startup, with 1 second delay between each retry, set to 0 to retry indefinitely. | `15` |
| `database.maxConnections` | Define the size of the connection pool used for connecting to the database. | `10` |

### Push notifications

Expand Down
27 changes: 26 additions & 1 deletion charts/vaultwarden/templates/_podSpec.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,32 @@ containers:
- name: DISABLE_ADMIN_TOKEN
value: "true"
{{- end }}
{{- if ne "default" .Values.database.type }}
{{- if and ( eq .Values.database.type "postgresql") .Values.database.existingSecret (not .Values.database.existingSecretKey)}}
- name: DATABASE_URL
value: "postgresql://{{ .Values.database.host }}"
- name: PGPORT
value: {{ .Values.database.port | quote }}
- name: PGDATABASE
value: {{ .Values.database.dbName | quote }}
- name: PGUSER
{{- if .Values.database.existingSecretUserKey}}
valueFrom:
secretKeyRef:
name: {{ .Values.database.existingSecret | quote }}
key: {{ .Values.database.existingSecretUserKey | quote }}
{{- else }}
value: {{ .Values.database.username | quote }}
{{- end }}
- name: PGPASSWORD
{{- if .Values.database.existingSecretPasswordKey}}
valueFrom:
secretKeyRef:
name: {{ .Values.database.existingSecret | quote }}
key: {{ .Values.database.existingSecretPasswordKey | quote }}
{{- else }}
value: {{ .Values.database.password }}
{{- end }}
{{- else if ne "default" .Values.database.type }}
- name: DATABASE_URL
{{- if .Values.database.existingSecret }}
valueFrom:
Expand Down
8 changes: 7 additions & 1 deletion charts/vaultwarden/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,18 @@ database:
## @param database.uriOverride Manually specify the DB connection string
##
uriOverride: ""
## @param database.existingSecret Name of an existing secret containing the database URI
## @param database.existingSecret Name of an existing secret containing either a single key with the database uri, or a separate key for username and password
##
existingSecret: ""
## @param database.existingSecretKey Key in the existing secret
##
existingSecretKey: ""
## @param database.existingSecretUserKey Key in the existing secret
##
existingSecretUserKey: username
## @param database.existingSecretPasswordKey Key in the existing secret
##
existingSecretPasswordKey: password
## @param database.connectionRetries Number of times to retry the database connection during startup, with 1 second delay between each retry, set to 0 to retry indefinitely.
##
connectionRetries: 15
Expand Down