From 75e54e76a0285522c9b8d3132edd8d7442b98084 Mon Sep 17 00:00:00 2001 From: Kjeld Schouten-Lebbing Date: Thu, 9 Sep 2021 17:15:46 +0200 Subject: [PATCH] fix: Inject vaultwarden websocket part into ingress (#946) --- .../stable/vaultwarden/templates/common.yaml | 31 ++++++++- charts/stable/vaultwarden/values.yaml | 68 +++++++++++++++++++ 2 files changed, 97 insertions(+), 2 deletions(-) diff --git a/charts/stable/vaultwarden/templates/common.yaml b/charts/stable/vaultwarden/templates/common.yaml index 74f04d2d8c2..6af2072556b 100644 --- a/charts/stable/vaultwarden/templates/common.yaml +++ b/charts/stable/vaultwarden/templates/common.yaml @@ -1,11 +1,38 @@ {{/* Make sure all variables are set properly */}} {{- include "common.values.setup" . }} -{{/* Render the templates */}} -{{ include "common.all" . }} {{/* Render configmap for vaultwarden */}} {{- include "vaultwarden.configmap" . }} {{/* Render secrets for vaultwarden */}} {{- include "vaultwarden.secrets" . }} + +{{/* Define path for websocket */}} +{{- define "vaultwarden.websocket" -}} +path: "/notifications/hub" +# -- Ignored if not kubeVersion >= 1.14-0 +pathType: Prefix +service: + # -- Overrides the service name reference for this path + name: ws + port: {{ .Values.service.ws.ports.ws.port }} +{{- end -}} + +{{/* inject websocket path to all main ingress hosts*/}} +{{- define "vaultwarden.websocketinjector" -}} +{{- $path := list (include "vaultwarden.websocket" . | fromYaml) -}} +{{- if .Values.ingress.main.enabled }} +{{- range .Values.ingress.main.hosts }} +{{- $newpaths := list }} +{{- $newpaths := concat .paths $path }} +{{- $_ := set . "paths" ( deepCopy $newpaths ) -}} +{{- end }} +{{- end }} +{{- end -}} + +{{/* inject websocket paths in ingress */}} +{{- include "vaultwarden.websocketinjector" . }} + +{{/* Render the templates */}} +{{ include "common.all" . }} diff --git a/charts/stable/vaultwarden/values.yaml b/charts/stable/vaultwarden/values.yaml index 36d17472fe9..cb40e087e26 100644 --- a/charts/stable/vaultwarden/values.yaml +++ b/charts/stable/vaultwarden/values.yaml @@ -21,6 +21,74 @@ service: env: {} +# -- Configure the ingresses for the chart here. +# Additional ingresses can be added by adding a dictionary key similar to the 'main' ingress. +# @default -- See below +ingress: + main: + # -- Enables or disables the ingress + enabled: true + + # -- Make this the primary ingress (used in probes, notes, etc...). + # If there is more than 1 ingress, make sure that only 1 ingress is marked as primary. + primary: true + + # -- Override the name suffix that is used for this ingress. + nameOverride: + + # -- List of middlewares in the traefikmiddlewares k8s namespace to add automatically + # Creates an annotation with the middlewares and appends k8s and traefik namespaces to the middleware names + # Primarily used for TrueNAS SCALE to add additional (seperate) middlewares without exposing them to the end-user + fixedMiddlewares: + - chain-basic + + # -- Additional List of middlewares in the traefikmiddlewares k8s namespace to add automatically + # Creates an annotation with the middlewares and appends k8s and traefik namespaces to the middleware names + middlewares: [] + annotationsList: [] + # - name: somename + # value: somevalue + # -- Provide additional annotations which may be required. + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + + labelsList: [] + # - name: somename + # value: somevalue + # -- Set labels on the deployment/statefulset/daemonset + # -- Provide additional labels which may be required. + # -- Provide additional labels which may be required. + labels: {} + + # -- Set the ingressClass that is used for this ingress. + # Requires Kubernetes >=1.19 + ingressClassName: # "nginx" + + ## Configure the hosts for the ingress + hosts: + - # -- Host address. Helm template can be passed. + host: chart-example.local + ## Configure the paths for the host + paths: + - # -- Path. Helm template can be passed. + path: / + # -- Ignored if not kubeVersion >= 1.14-0 + pathType: Prefix + service: + # -- Overrides the service name reference for this path + name: + # -- Overrides the service port reference for this path + port: + + # -- Configure TLS for the ingress. Both secretName and hosts can process a Helm template. + tls: [] + # - secretName: chart-example-tls + # -- Create a secret from a GUI selected TrueNAS SCALE certificate + # scaleCert: true + # hosts: + # - chart-example.local + initContainers: - name: init-postgresdb image: postgres:13.1