Add vaultwarden

This commit is contained in:
2023-10-06 22:09:48 +08:00
parent 75d720a37a
commit 9be4ff1f35
15 changed files with 1469 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ .Values.ingress.host }}/
{{- else if .Values.ingressRoute.enabled }}
http{{ if $.Values.ingressRoute.tls }}s{{ end }}://{{ .Values.ingressRoute.host }}/
{{- else }}
{{- if eq .Values.vaultwarden.enableWebsockets true }}
NOTE: the websocket listens on a different port and might not work unless /notifications/hub is redirected externally.
{{- end }}
{{- if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "vaultwarden.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "vaultwarden.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "vaultwarden.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.httpPort }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "vaultwarden.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:8080
{{- end }}
{{- end }}
+105
View File
@@ -0,0 +1,105 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "vaultwarden.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "vaultwarden.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "vaultwarden.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "vaultwarden.labels" -}}
helm.sh/chart: {{ include "vaultwarden.chart" . }}
{{ include "vaultwarden.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "vaultwarden.selectorLabels" -}}
app.kubernetes.io/name: {{ include "vaultwarden.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "vaultwarden.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "vaultwarden.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
{{/*
Ensure valid DB type is select, defaults to SQLite
*/}}
{{- define "vaultwarden.dbTypeValid" -}}
{{- if not (or (eq .Values.database.type "postgresql") (eq .Values.database.type "mysql") (eq .Values.database.type "sqlite")) }}
{{- required "Invalid database type" nil }}
{{- end -}}
{{- end -}}
{{/*
Ensure log type is valid
*/}}
{{- define "vaultwarden.logLevelValid" -}}
{{- if not (or (eq .Values.vaultwarden.log.level "trace") (eq .Values.vaultwarden.log.level "debug") (eq .Values.vaultwarden.log.level "info") (eq .Values.vaultwarden.log.level "warn") (eq .Values.vaultwarden.log.level "error") (eq .Values.vaultwarden.log.level "off")) }}
{{- required "Invalid log level" nil }}
{{- end }}
{{- end }}
{{/*
Ensure SMTP Security setting is valid
*/}}
{{- define "vaultwarden.smtpSecurityValid" -}}
{{- if or (hasKey .Values.vaultwarden.smtp "ssl") (hasKey .Values.vaultwarden.smtp "explicitTLS") }}
{{- required "SMTP options ssl and explicitTLS are deprecated for Vaulwarden 1.25 or newer, see documentation" nil }}
{{- end }}
{{- if not (or (eq .Values.vaultwarden.smtp.security "off") (eq .Values.vaultwarden.smtp.security "starttls") (eq .Values.vaultwarden.smtp.security "force_tls") ) }}
{{- required "Invalid SMTP security setting, valid options are: off, starttls and force_tls" nil }}
{{- end }}
{{- end }}
{{- define "vaultwarden.domainSubPath" -}}
{{- if .Values.vaultwarden.domain }}
{{- if not (regexMatch "https?:\\/\\/.*?(\\/|$)" .Values.vaultwarden.domain) }}
{{- required "Invalid domain, must start with http or https" nil }}
{{- end }}
{{- $subpath := regexReplaceAll "https?:\\/\\/.*?(\\/|$)" .Values.vaultwarden.domain "" -}}/{{ $subpath }}
{{- else }}/
{{- end }}
{{- end -}}
+342
View File
@@ -0,0 +1,342 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "vaultwarden.fullname" . }}
labels:
{{- include "vaultwarden.labels" . | nindent 4 }}
{{- with .Values.deploymentAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- with .Values.strategy }}
strategy:
{{- toYaml . | nindent 4 }}
{{- end }}
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "vaultwarden.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "vaultwarden.selectorLabels" . | nindent 8 }}
{{- if .Values.podLabels }}
{{- toYaml .Values.podLabels | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "vaultwarden.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: ROCKET_PORT
value: "8080"
- name: SIGNUPS_ALLOWED
value: {{ .Values.vaultwarden.allowSignups | quote }}
{{- if .Values.vaultwarden.signupDomains }}
- name: SIGNUPS_DOMAINS_WHITELIST
value: {{ join "," .Values.vaultwarden.signupDomains | quote }}
{{- end }}
{{- if and (eq .Values.vaultwarden.verifySignup true) (eq .Values.vaultwarden.smtp.enabled false) }}{{ required "Signup verification requires SMTP to be enabled" nil}}{{end}}
- name: SIGNUPS_VERIFY
value: {{ .Values.vaultwarden.verifySignup | quote }}
{{- if and (eq .Values.vaultwarden.requireEmail true) (eq .Values.vaultwarden.smtp.enabled false) }}{{ required "Requiring emails for login depends on SMTP" nil}}{{end}}
- name: REQUIRE_DEVICE_EMAIL
value: {{ .Values.vaultwarden.requireEmail | quote }}
{{- if .Values.vaultwarden.emailAttempts }}
- name: EMAIL_ATTEMPTS_LIMIT
value: {{ .Values.vaultwarden.emailAttempts | quote }}
{{- end }}
{{- if .Values.vaultwarden.emailTokenExpiration }}
- name: EMAIL_EXPIRATION_TIME
value: {{ .Values.vaultwarden.emailTokenExpiration | quote }}
{{- end }}
- name: INVITATIONS_ALLOWED
value: {{ .Values.vaultwarden.allowInvitation | quote }}
{{- if .Values.vaultwarden.invitationExpiration }}
- name: INVITATION_EXPIRATION_HOURS
value: {{ .Values.vaultwarden.invitationExpiration | quote }}
{{- end }}
{{- if .Values.vaultwarden.defaultInviteName }}
- name: INVITATION_ORG_NAME
value: {{ .Values.vaultwarden.defaultInviteName | quote }}
{{- end }}
{{- if hasKey .Values.vaultwarden "passwordHintsAllowed" }}
- name: PASSWORD_HINTS_ALLOWED
value: {{ .Values.vaultwarden.passwordHintsAllowed | quote }}
{{- end }}
- name: SHOW_PASSWORD_HINT
value: {{ .Values.vaultwarden.showPasswordHint | quote }}
- name: WEBSOCKET_ENABLED
value: {{ .Values.vaultwarden.enableWebsockets | quote }}
- name: WEB_VAULT_ENABLED
value: {{ .Values.vaultwarden.enableWebVault | quote }}
- name: SENDS_ALLOWED
value: {{ .Values.vaultwarden.enableSends | quote }}
- name: ORG_CREATION_USERS
value: {{ .Values.vaultwarden.orgCreationUsers | quote }}
{{- if .Values.vaultwarden.attachmentLimitOrg }}
- name: ORG_ATTACHMENT_LIMIT
value: {{ .Values.vaultwarden.attachmentLimitOrg | quote }}
{{- end }}
{{- if .Values.vaultwarden.attachmentLimitUser }}
- name: USER_ATTACHMENT_LIMIT
value: {{ .Values.vaultwarden.attachmentLimitUser | quote }}
{{- end }}
{{- if .Values.vaultwarden.hibpApiKey }}
- name: HIBP_API_KEY
value: {{ .Values.vaultwarden.hibpApiKey | quote }}
{{- end }}
{{- if .Values.vaultwarden.autoDeleteDays }}
- name: TRASH_AUTO_DELETE_DAYS
value: {{ .Values.vaultwarden.autoDeleteDays | quote }}
{{- end }}
{{- if hasKey .Values.vaultwarden "orgEvents" }}
- name: ORG_EVENTS_ENABLED
value: {{ .Values.vaultwarden.orgEvents | quote }}
{{- end }}
{{- if hasKey .Values.vaultwarden "orgEventsRetention" }}
- name: EVENTS_DAYS_RETAIN
value: {{ .Values.vaultwarden.orgEventsRetention | quote }}
{{- end }}
{{- if .Values.vaultwarden.extraEnv }}
{{- range $key, $val := .Values.vaultwarden.extraEnv }}
- name: {{ $key }}
value: {{ $val | quote }}
{{- end }}
{{- end }}
{{- include "vaultwarden.dbTypeValid" . }}
{{- if .Values.database.retries }}
- name: DB_CONNECTION_RETRIES
value: {{ .Values.database.retries | quote }}
{{- end }}
{{- if .Values.database.maxConnections }}
- name: DATABASE_MAX_CONNS
value: {{ .Values.database.maxConnections | quote }}
{{- end }}
{{- if eq .Values.database.type "sqlite" }}
- name: ENABLE_DB_WAL
value: {{ .Values.database.wal | quote }}
{{- else }}
- name: ENABLE_DB_WAL
value: "false"
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: {{ if .Values.database.existingSecret }}{{ .Values.database.existingSecret }}{{else}}{{ include "vaultwarden.fullname" . }}{{end}}
key: database-url
{{- end }}
{{- if .Values.vaultwarden.domain }}
- name: DOMAIN
value: {{ .Values.vaultwarden.domain | quote }}
{{- end }}
{{- if eq .Values.vaultwarden.admin.enabled true }}
{{- if eq .Values.vaultwarden.admin.disableAdminToken true }}
- name: DISABLE_ADMIN_TOKEN
value: "true"
{{- else }}
- name: ADMIN_TOKEN
valueFrom:
secretKeyRef:
name: {{ .Values.vaultwarden.admin.existingSecret | default (include "vaultwarden.fullname" .) }}
key: admin-token
{{- end }}
{{- end }}
- name: EMERGENCY_ACCESS_ALLOWED
value: {{ .Values.vaultwarden.emergency.enabled | quote }}
{{- if eq .Values.vaultwarden.emergency.enabled true }}
{{- if not (kindIs "invalid" .Values.vaultwarden.emergency.reminder) }}
- name: EMERGENCY_NOTIFICATION_REMINDER_SCHEDULE
value: {{ .Values.vaultwarden.emergency.reminder | quote }}
{{- end }}
{{- if not (kindIs "invalid" .Values.vaultwarden.emergency.timeout) }}
- name: EMERGENCY_REQUEST_TIMEOUT_SCHEDULE
value: {{ .Values.vaultwarden.emergency.timeout | quote }}
{{- end }}
{{- end }}
{{- if eq .Values.vaultwarden.smtp.enabled true }}
- name: SMTP_HOST
value: {{ required "SMTP host is required to enable SMTP" .Values.vaultwarden.smtp.host | quote }}
- name: SMTP_FROM
value: {{ required "SMTP sender address ('from') is required to enable SMTP" .Values.vaultwarden.smtp.from | quote }}
{{- if .Values.vaultwarden.smtp.fromName }}
- name: SMTP_FROM_NAME
value: {{ .Values.vaultwarden.smtp.fromName | quote }}
{{- end }}
{{- if semverCompare "<1.25.0" (.Values.image.tag | default .Chart.AppVersion) }}
- name: SMTP_SSL
value: {{ required "Value smtp.ssl required for Vaultwarden prior to 1.25" .Values.vaultwarden.smtp.ssl | quote }}
{{- if required "Value smtp.explictTLS required for Vaultwarden prior to 1.25" .Values.vaultwarden.smtp.explicitTLS }}
{{- if (eq .Values.vaultwarden.smtp.ssl false) }}
{{- required "Explicit TLS requires SSL to be enabled" nil }}
{{- end }}
- name: SMTP_EXPLICIT_TLS
value: {{ .Values.vaultwarden.smtp.explicitTLS | quote }}
{{- end}}
{{- else }}
{{- include "vaultwarden.smtpSecurityValid" . }}
- name: SMTP_SECURITY
value: {{ .Values.vaultwarden.smtp.security | quote }}
{{- end }}
{{- if .Values.vaultwarden.smtp.port }}
- name: SMTP_PORT
value: {{ .Values.vaultwarden.smtp.port | quote }}
{{- end }}
{{- if .Values.vaultwarden.smtp.authMechanism }}
- name: SMTP_AUTH_MECHANISM
value: {{ .Values.vaultwarden.smtp.authMechanism | quote }}
{{- end }}
{{- if .Values.vaultwarden.smtp.heloName }}
- name: HELO_NAME
value: {{ .Values.vaultwarden.smtp.heloName | quote }}
{{- end }}
{{- if .Values.vaultwarden.smtp.timeout }}
- name: SMTP_TIMEOUT
value: {{ .Values.vaultwarden.smtp.timeout | quote }}
{{- end }}
{{- if .Values.vaultwarden.smtp.invalidHostname }}
- name: SMTP_ACCEPT_INVALID_HOSTNAMES
value: {{ .Values.vaultwarden.smtp.invalidHostname | quote }}
{{- end }}
{{- if .Values.vaultwarden.smtp.invalidCertificate }}
- name: SMTP_ACCEPT_INVALID_CERTS
value: {{ .Values.vaultwarden.smtp.invalidCertificate | quote }}
{{- end }}
{{- if or .Values.vaultwarden.smtp.existingSecret .Values.vaultwarden.smtp.user }}
- name: SMTP_USERNAME
valueFrom:
secretKeyRef:
name: {{ .Values.vaultwarden.smtp.existingSecret | default (include "vaultwarden.fullname" .) }}
key: smtp-user
- name: SMTP_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.vaultwarden.smtp.existingSecret | default (include "vaultwarden.fullname" .) }}
key: smtp-password
{{- end }}
{{- if hasKey .Values.vaultwarden.smtp "embedImages" }}
- name: SMTP_EMBED_IMAGES
value: {{ .Values.vaultwarden.smtp.embedImages | quote }}
{{- end }}
{{- end }}{{/*SMTP*/}}
{{- if eq .Values.vaultwarden.yubico.enabled true }}
{{- if .Values.vaultwarden.yubico.server }}
- name: YUBICO_SERVER
value: {{ .Values.vaultwarden.yubico.server | quote }}
{{- end }}
- name: YUBICO_CLIENT_ID
valueFrom:
secretKeyRef:
name: {{ .Values.vaultwarden.yubico.existingSecret | default (include "vaultwarden.fullname" .) }}
key: yubico-client-id
- name: YUBICO_SECRET_KEY
valueFrom:
secretKeyRef:
name: {{ .Values.vaultwarden.yubico.existingSecret | default (include "vaultwarden.fullname" .) }}
key: yubico-secret-key
{{- end }}
{{- if .Values.vaultwarden.log.file }}
- name: LOG_FILE
value: {{ .Values.vaultwarden.log.file | quote }}
{{- end }}
{{- if or .Values.vaultwarden.log.level .Values.vaultwarden.log.timeFormat }}
- name: EXTENDED_LOGGING
value: "true"
{{- end }}
{{- if .Values.vaultwarden.log.level }}
{{- include "vaultwarden.logLevelValid" . }}
- name: LOG_LEVEL
value: {{ .Values.vaultwarden.log.level | quote }}
{{- end }}
{{- if .Values.vaultwarden.log.timeFormat }}
- name: LOG_TIMESTAMP_FORMAT
value: {{ .Values.vaultwarden.log.timeFormat | quote }}
{{- end }}
{{- if hasKey .Values.vaultwarden.icons "service" }}
- name: ICON_SERVICE
value: {{ .Values.vaultwarden.icons.service | quote }}
{{- end }}
{{- if .Values.vaultwarden.icons.disableDownload }}
- name: DISABLE_ICON_DOWNLOAD
value: {{ .Values.vaultwarden.icons.disableDownload | quote }}
{{- if and (not .Values.vaultwarden.icons.cache) (eq .Values.vaultwarden.icons.disableDownload "true") }}
- name: ICON_CACHE_TTL
value: 0
{{- end }}
{{- end }}
{{- if .Values.vaultwarden.icons.cache }}
- name: ICON_CACHE_TTL
value: {{ .Values.vaultwarden.icons.cache }}
{{- end }}
{{- if .Values.vaultwarden.icons.cacheFailed }}
- name: ICON_CACHE_NEGTTL
value: {{ .Values.vaultwarden.icons.cacheFailed }}
{{- end }}
{{- if hasKey .Values.vaultwarden.icons "redirectCode" }}
- name: ICON_REDIRECT_CODE
value: {{ .Values.vaultwarden.icons.redirectCode | quote }}
{{- end }}
ports:
- name: http
containerPort: 8080
protocol: TCP
{{- if .Values.vaultwarden.enableWebsockets }}
- name: websocket
containerPort: 3012
protocol: TCP
{{- end }}
livenessProbe:
httpGet:
path: {{ include "vaultwarden.domainSubPath" . }}
port: http
readinessProbe:
httpGet:
path: {{ include "vaultwarden.domainSubPath" . }}
port: http
volumeMounts:
- name: {{ include "vaultwarden.fullname" . }}
mountPath: /data
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- if .Values.sidecars }}
{{- toYaml .Values.sidecars | nindent 8 }}
{{- end }}
volumes:
- name: {{ include "vaultwarden.fullname" . }}
{{- if and .Values.persistence.enabled .Values.customVolume }}
{{ required "customVolume cannot be used if persistence is enabled." nil }}
{{- end }}
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim | quote }}{{- else }}{{ include "vaultwarden.fullname" . }}{{- end }}
{{- else if .Values.customVolume }}
{{- toYaml .Values.customVolume | nindent 8 }}
{{- else }}
emptyDir: {}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
+67
View File
@@ -0,0 +1,67 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "vaultwarden.fullname" . -}}
{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" -}}
apiVersion: networking.k8s.io/v1
{{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1/Ingress" -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "vaultwarden.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.className }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
- host: {{ required "Host required for ingress" .Values.ingress.host | quote }}
http:
paths:
{{- if .Values.vaultwarden.enableWebsockets }}
- path: "/notifications/hub"
{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
pathType: Prefix
{{- end }}
backend:
{{- if $.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
service:
name: {{ $fullName }}
port:
number: {{ .Values.service.websocketPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ .Values.service.websocketPort }}
{{- end }}
{{- end }}
- path: "/"
{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
pathType: Prefix
{{- end }}
backend:
{{- if $.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
service:
name: {{ $fullName }}
port:
number: {{ .Values.service.httpPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ .Values.service.httpPort }}
{{- end }}
{{- end }}
+40
View File
@@ -0,0 +1,40 @@
{{- if .Values.ingressRoute.enabled -}}
{{- $fullName := include "vaultwarden.fullname" . -}}
{{- $host := (required "Host required for IngressRoute" .Values.ingressRoute.host ) -}}
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: {{ $fullName }}
labels:
{{- include "vaultwarden.labels" . | nindent 4 }}
spec:
entryPoints:
{{- range .Values.ingressRoute.entrypoints }}
- {{ . | quote }}
{{- end }}
routes:
{{- if .Values.vaultwarden.enableWebsockets }}
- match: Host(`{{ $host }}`) && PathPrefix(`/notifications/hub`)
kind: Rule
{{- if .Values.ingressRoute.middlewares }}
middlewares:
{{- toYaml .Values.ingressRoute.middlewares | nindent 6 }}
{{- end }}
services:
- name: {{ $fullName }}
port: {{ .Values.service.websocketPort }}
{{- end }}
- match: Host(`{{ $host }}`)
kind: Rule
{{- if .Values.ingressRoute.middlewares }}
middlewares:
{{- toYaml .Values.ingressRoute.middlewares | nindent 6 }}
{{- end }}
services:
- name: {{ $fullName }}
port: {{ .Values.service.httpPort }}
{{- if .Values.ingressRoute.tls }}
tls:
{{- toYaml .Values.ingressRoute.tls | nindent 4 }}
{{- end }}
{{- end }}
+15
View File
@@ -0,0 +1,15 @@
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) -}}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ include "vaultwarden.fullname" . }}
spec:
accessModes:
- {{ .Values.persistence.accessMode | quote }}
resources:
requests:
storage: {{ .Values.persistence.size | quote }}
{{- if .Values.persistence.storageClass }}
storageClassName: {{ .Values.persistence.storageClass | quote }}
{{- end }}
{{- end -}}
+43
View File
@@ -0,0 +1,43 @@
{{- $adminToken := "" }}
{{- if and (eq .Values.vaultwarden.admin.enabled true) (not .Values.vaultwarden.admin.existingSecret) }}
{{- $adminToken = .Values.vaultwarden.admin.token | default (randAlphaNum 48) | b64enc | quote }}
{{- end -}}
{{- $databaseUrl := "" }}
{{- if and (ne .Values.database.type "sqlite") (not .Values.database.existingSecret) }}
{{- $databaseUrl = required "External databases need either URL or existing secret" .Values.database.url | b64enc | quote }}
{{- end -}}
{{- $smtpUser := "" }}
{{- if and (eq .Values.vaultwarden.smtp.enabled true ) (not .Values.vaultwarden.smtp.existingSecret) (.Values.vaultwarden.smtp.user) }}
{{- $smtpUser = .Values.vaultwarden.smtp.user | b64enc | quote }}
{{- end -}}
{{- $yubicoClientId := "" }}
{{- if and (eq .Values.vaultwarden.yubico.enabled true ) (not .Values.vaultwarden.yubico.existingSecret) }}
{{- $yubicoClientId = required "Yubico Client ID required" .Values.vaultwarden.yubico.clientId | toString | b64enc | quote }}
{{- end -}}
{{- if or (ne $adminToken "") (ne $databaseUrl "") (ne $smtpUser "" ) (ne $yubicoClientId "") }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "vaultwarden.fullname" . }}
labels:
{{- include "vaultwarden.labels" . | nindent 4 }}
data:
{{- if ne $adminToken "" }}
admin-token: {{ $adminToken }}
{{- end }}
{{- if ne $databaseUrl "" }}
database-url: {{ $databaseUrl }}
{{- end }}
{{- if ne $smtpUser "" }}
smtp-user: {{ $smtpUser }}
smtp-password: {{ required "Must specify SMTP password" .Values.vaultwarden.smtp.password | b64enc | quote }}
{{- end }}
{{- if ne $yubicoClientId "" }}
yubico-client-id: {{ $yubicoClientId }}
yubico-secret-key: {{ required "Yubico Secret Key required" .Values.vaultwarden.yubico.secretKey | b64enc | quote }}
{{- end }}
{{- end }}
+33
View File
@@ -0,0 +1,33 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "vaultwarden.fullname" . }}
labels:
{{- include "vaultwarden.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
{{- if (or (eq .Values.service.type "LoadBalancer") (eq .Values.service.type "NodePort")) }}
externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy | quote }}
{{- end }}
{{- if eq .Values.service.type "LoadBalancer" }}
loadBalancerIP: {{ default "" .Values.service.loadBalancerIP }}
{{- end }}
ports:
- name: http
port: {{ .Values.service.httpPort }}
targetPort: http
protocol: TCP
{{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePorts.http)))}}
nodePort: {{ .Values.service.nodePorts.http }}
{{- end }}
{{- if .Values.vaultwarden.enableWebsockets }}
- name: websocket
port: {{ .Values.service.websocketPort }}
targetPort: websocket
protocol: TCP
{{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePorts.websocket)))}}
nodePort: {{ .Values.service.nodePorts.websocket }}
{{- end }}
{{- end }}
selector:
{{- include "vaultwarden.selectorLabels" . | nindent 4 }}
+12
View File
@@ -0,0 +1,12 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "vaultwarden.serviceAccountName" . }}
labels:
{{- include "vaultwarden.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "vaultwarden.fullname" . }}-test-connection"
labels:
{{- include "vaultwarden.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test-success
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "vaultwarden.fullname" . }}:{{ .Values.service.httpPort }}']
restartPolicy: Never