From df13abf94a0c91555a091c6bcedd5c7958a4bbe2 Mon Sep 17 00:00:00 2001 From: "Nicholas St. Germain" Date: Sun, 16 Aug 2020 19:53:28 -0500 Subject: [PATCH] [bitwarden_rs] New chart (#327) * add bitwarden_rs chart * Silly lint opinion fix * Maintainer Name > Github Username * add templated fullname for nested include * push rename * tweaks * update readme and secret * fix existing secret reference --- charts/bitwardenrs/.helmignore | 23 +++ charts/bitwardenrs/Chart.yaml | 19 +++ charts/bitwardenrs/OWNERS | 4 + charts/bitwardenrs/README.md | 48 +++++++ charts/bitwardenrs/templates/NOTES.txt | 21 +++ charts/bitwardenrs/templates/_helpers.tpl | 63 +++++++++ charts/bitwardenrs/templates/configmap.yaml | 36 +++++ charts/bitwardenrs/templates/deployment.yaml | 120 ++++++++++++++++ charts/bitwardenrs/templates/hpa.yaml | 28 ++++ charts/bitwardenrs/templates/ingress.yaml | 41 ++++++ charts/bitwardenrs/templates/pvc.yaml | 15 ++ charts/bitwardenrs/templates/secret.yaml | 11 ++ charts/bitwardenrs/templates/service.yaml | 28 ++++ .../bitwardenrs/templates/serviceaccount.yaml | 12 ++ charts/bitwardenrs/templates/statefulset.yaml | 121 ++++++++++++++++ .../templates/tests/test-connection.yaml | 15 ++ charts/bitwardenrs/values.yaml | 132 ++++++++++++++++++ 17 files changed, 737 insertions(+) create mode 100644 charts/bitwardenrs/.helmignore create mode 100644 charts/bitwardenrs/Chart.yaml create mode 100644 charts/bitwardenrs/OWNERS create mode 100644 charts/bitwardenrs/README.md create mode 100644 charts/bitwardenrs/templates/NOTES.txt create mode 100644 charts/bitwardenrs/templates/_helpers.tpl create mode 100644 charts/bitwardenrs/templates/configmap.yaml create mode 100644 charts/bitwardenrs/templates/deployment.yaml create mode 100644 charts/bitwardenrs/templates/hpa.yaml create mode 100644 charts/bitwardenrs/templates/ingress.yaml create mode 100644 charts/bitwardenrs/templates/pvc.yaml create mode 100644 charts/bitwardenrs/templates/secret.yaml create mode 100644 charts/bitwardenrs/templates/service.yaml create mode 100644 charts/bitwardenrs/templates/serviceaccount.yaml create mode 100644 charts/bitwardenrs/templates/statefulset.yaml create mode 100644 charts/bitwardenrs/templates/tests/test-connection.yaml create mode 100644 charts/bitwardenrs/values.yaml diff --git a/charts/bitwardenrs/.helmignore b/charts/bitwardenrs/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/charts/bitwardenrs/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/bitwardenrs/Chart.yaml b/charts/bitwardenrs/Chart.yaml new file mode 100644 index 00000000..57cdd119 --- /dev/null +++ b/charts/bitwardenrs/Chart.yaml @@ -0,0 +1,19 @@ +apiVersion: v2 +name: bitwardenrs +description: Unofficial Bitwarden compatible server written in Rust +type: application +version: 0.1.0 +appVersion: 1.16.3 +keywords: + - bitwarden + - bitwardenrs + - bitwarden_rs + - password + - rust +home: https://github.com/billimek/billimek-charts/tree/master/charts/bitwarden_rs +sources: + - https://github.com/dani-garcia/bitwarden_rs +maintainers: + - name: DirtyCajunRice + email: nick@cajun.pro +icon: https://raw.githubusercontent.com/bitwarden/brand/master/icons/256x256.png diff --git a/charts/bitwardenrs/OWNERS b/charts/bitwardenrs/OWNERS new file mode 100644 index 00000000..90661f99 --- /dev/null +++ b/charts/bitwardenrs/OWNERS @@ -0,0 +1,4 @@ +approvers: +- DirtyCajunRice +reviewers: +- DirtyCajunRice \ No newline at end of file diff --git a/charts/bitwardenrs/README.md b/charts/bitwardenrs/README.md new file mode 100644 index 00000000..979d7ab5 --- /dev/null +++ b/charts/bitwardenrs/README.md @@ -0,0 +1,48 @@ +# Unofficial Bitwarden compatible server written in Rust + +This is an opinionated helm chart for [bitwarden_rs](https://github.com/dani-garcia/bitwarden_rs) + +The default values and container images used in this chart will allow for running in a multi-arch cluster (amd64, arm, arm64) + +## TL;DR + +```console +helm repo add billimek https://billimek.com/billimek-charts/ +helm install billimek/bitwardenrs +``` + +## Installing the Chart + +To install the chart with the release name `bitwarden`: + +```console +helm install bitwarden billimek/bitwardenrs +``` + +## Uninstalling the Chart + +To uninstall/delete the `bitwarden` deployment: + +```console +helm uninstall bitwarden +``` + +The command removes all the Kubernetes components associated with the chart and deletes the release. + +## Configuration + +Read through the [values.yaml](https://github.com/billimek/billimek-charts/blob/master/charts/bitwardenrs/values.yaml) file. It has several commented out suggested values. + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, + +```console +helm install bitwarden \ + --set timeZone="America/New York" \ + billimek/bitwardenrs +``` + +Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example, + +```console +helm install bitwarden billimek/bitwardenrs --values values.yaml +``` diff --git a/charts/bitwardenrs/templates/NOTES.txt b/charts/bitwardenrs/templates/NOTES.txt new file mode 100644 index 00000000..2beeb507 --- /dev/null +++ b/charts/bitwardenrs/templates/NOTES.txt @@ -0,0 +1,21 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "bitwardenrs.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 "bitwardenrs.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "bitwardenrs.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "bitwardenrs.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:80 +{{- end }} diff --git a/charts/bitwardenrs/templates/_helpers.tpl b/charts/bitwardenrs/templates/_helpers.tpl new file mode 100644 index 00000000..f1b1b1d5 --- /dev/null +++ b/charts/bitwardenrs/templates/_helpers.tpl @@ -0,0 +1,63 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "bitwardenrs.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 "bitwardenrs.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 "bitwardenrs.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "bitwardenrs.labels" -}} +helm.sh/chart: {{ include "bitwardenrs.chart" . }} +{{ include "bitwardenrs.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "bitwardenrs.selectorLabels" -}} +app.kubernetes.io/name: {{ include "bitwardenrs.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "bitwardenrs.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "bitwardenrs.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/bitwardenrs/templates/configmap.yaml b/charts/bitwardenrs/templates/configmap.yaml new file mode 100644 index 00000000..e7a5216f --- /dev/null +++ b/charts/bitwardenrs/templates/configmap.yaml @@ -0,0 +1,36 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "bitwardenrs.fullname" . }} + labels: + {{- include "bitwardenrs.labels" . | nindent 4 }} +data: + SIGNUPS_ALLOWED: {{ .Values.bitwardenrs.signupsAllowed | quote }} + {{- if .Values.bitwardenrs.domain }} + DOMAIN: {{ .Values.bitwardenrs.domain | quote }} + {{- end }} + WEBSOCKET_ENABLED: {{ .Values.bitwardenrs.websockets.enabled | quote }} + {{- if and .Values.bitwardenrs.admin.enabled .Values.bitwardenrs.admin.disableAdminToken }} + DISABLE_ADMIN_TOKEN: "true" + {{- end }} + {{- with .Values.bitwardenrs.smtp }} + {{- if .enabled }} + SMTP_HOST: {{ required "SMTP host is required to enable SMTP" .host | quote }} + SMTP_FROM: {{ required "SMTP sender address ('from') is required to enable SMTP" .from | quote }} + {{- if .fromName }} + SMTP_FROM_NAME: {{ .fromName | quote }} + {{- end }} + {{- if .ssl }} + SMTP_SSL: {{ .ssl | quote }} + {{- end }} + {{- if .port }} + SMTP_PORT: {{ .port | quote }} + {{- end }} + {{- if and (not .existingSecret.enabled) .user }} + SMTP_USERNAME: {{ .user | quote }} + {{- end }} + {{- end }} + {{- end }} + {{- if .Values.env }} + {{- toYaml .Values.env | nindent 2 }} + {{- end }} \ No newline at end of file diff --git a/charts/bitwardenrs/templates/deployment.yaml b/charts/bitwardenrs/templates/deployment.yaml new file mode 100644 index 00000000..34749a17 --- /dev/null +++ b/charts/bitwardenrs/templates/deployment.yaml @@ -0,0 +1,120 @@ +{{- if eq .Values.persistence.type "deployment" }} + {{- $fullName := include "bitwardenrs.fullname" . -}} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ $fullName }} + labels: + {{- include "bitwardenrs.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "bitwardenrs.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "bitwardenrs.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "bitwardenrs.serviceAccountName" . }} + {{- with .Values.podSecurityContext }} + securityContext: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: {{ $fullName }} + {{- with .Values.securityContext }} + securityContext: + {{- toYaml . | nindent 12 }} + {{- end }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + envFrom: + - configMapRef: + name: {{ $fullName }} + env: + {{- with .Values.bitwardenrs.admin }} + {{- if and .enabled (not .disableAdminToken) }} + - name: ADMIN_TOKEN + valueFrom: + secretKeyRef: + {{- if .existingSecret.enabled }} + name: {{ .existingSecret.name | quote }} + key: {{ .existingSecret.tokenKey | quote }} + {{- else }} + name: {{ $fullName }} + key: admin-token + {{- end }} + {{- end }} + {{- end }} + {{- with .Values.bitwardenrs.smtp }} + {{- if eq .enabled true }} + {{- if and .existingSecret.enabled (not .user) }} + - name: SMTP_USERNAME + valueFrom: + secretKeyRef: + name: {{ .existingSecret.name | quote }} + key: {{ .existingSecret.userKey | quote }} + - name: SMTP_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .existingSecret.name | quote }} + key: {{ .existingSecret.passwordKey | quote }} + {{- end }} + {{- end }} + {{- end }} + ports: + - name: http + containerPort: 80 + protocol: TCP + {{- if .Values.bitwardenrs.websockets.enabled }} + - name: websocket + containerPort: {{ .Values.bitwardenrs.websockets.port }} + protocol: TCP + {{- end }} + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + {{- with .Values.resources }} + resources: + {{- toYaml . | nindent 12 }} + {{- end }} + volumeMounts: + - name: {{ include "bitwardenrs.fullname" . }} + mountPath: /data + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + volumes: + - name: {{ include "bitwardenrs.fullname" . }} + {{- if .Values.persistence.enabled }} + persistentVolumeClaim: + claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim | quote }}{{- else }}{{ include "bitwardenrs.fullname" . }}{{- end }} + {{- else }} + emptyDir: {} + {{- end }} + {{- end }} \ No newline at end of file diff --git a/charts/bitwardenrs/templates/hpa.yaml b/charts/bitwardenrs/templates/hpa.yaml new file mode 100644 index 00000000..ad240b1a --- /dev/null +++ b/charts/bitwardenrs/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "bitwardenrs.fullname" . }} + labels: + {{- include "bitwardenrs.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "bitwardenrs.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/charts/bitwardenrs/templates/ingress.yaml b/charts/bitwardenrs/templates/ingress.yaml new file mode 100644 index 00000000..7766f068 --- /dev/null +++ b/charts/bitwardenrs/templates/ingress.yaml @@ -0,0 +1,41 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "bitwardenrs.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "bitwardenrs.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ . }} + backend: + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} diff --git a/charts/bitwardenrs/templates/pvc.yaml b/charts/bitwardenrs/templates/pvc.yaml new file mode 100644 index 00000000..29bf734d --- /dev/null +++ b/charts/bitwardenrs/templates/pvc.yaml @@ -0,0 +1,15 @@ +{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) -}} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ include "bitwardenrs.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 -}} \ No newline at end of file diff --git a/charts/bitwardenrs/templates/secret.yaml b/charts/bitwardenrs/templates/secret.yaml new file mode 100644 index 00000000..41eb4404 --- /dev/null +++ b/charts/bitwardenrs/templates/secret.yaml @@ -0,0 +1,11 @@ +{{- if not .Values.bitwardenrs.admin.existingSecret.enabled }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ template "bitwardenrs.fullname" . }} + labels: + {{- include "bitwardenrs.labels" . | nindent 4 }} +type: Opaque +data: + admin-token: {{ randAlphaNum 48 | b64enc | quote }} + {{- end }} \ No newline at end of file diff --git a/charts/bitwardenrs/templates/service.yaml b/charts/bitwardenrs/templates/service.yaml new file mode 100644 index 00000000..b9f163fa --- /dev/null +++ b/charts/bitwardenrs/templates/service.yaml @@ -0,0 +1,28 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "bitwardenrs.fullname" . }} + labels: + {{- include "bitwardenrs.labels" . | nindent 4 }} + {{- with .Values.service.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + {{- if .Values.bitwardenrs.websockets.enabled }} + - port: {{ .Values.bitwardenrs.websockets.port }} + targetPort: websocket + protocol: TCP + name: websocket + {{- end }} + {{- with .Values.service.additionalSpec }} + {{- toYaml . | nindent 2 }} + {{- end }} + selector: + {{- include "bitwardenrs.selectorLabels" . | nindent 4 }} diff --git a/charts/bitwardenrs/templates/serviceaccount.yaml b/charts/bitwardenrs/templates/serviceaccount.yaml new file mode 100644 index 00000000..c276c5d2 --- /dev/null +++ b/charts/bitwardenrs/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "bitwardenrs.serviceAccountName" . }} + labels: + {{- include "bitwardenrs.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/bitwardenrs/templates/statefulset.yaml b/charts/bitwardenrs/templates/statefulset.yaml new file mode 100644 index 00000000..09d02346 --- /dev/null +++ b/charts/bitwardenrs/templates/statefulset.yaml @@ -0,0 +1,121 @@ +{{- if eq .Values.persistence.type "statefulset" }} + {{- $fullName := include "bitwardenrs.fullname" . -}} +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ $fullName }} + labels: + {{- include "bitwardenrs.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "bitwardenrs.selectorLabels" . | nindent 6 }} + serviceName: {{ $fullName }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "bitwardenrs.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "bitwardenrs.serviceAccountName" . }} + {{- with .Values.podSecurityContext }} + securityContext: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: {{ $fullName }} + {{- with .Values.securityContext }} + securityContext: + {{- toYaml . | nindent 12 }} + {{- end }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + envFrom: + - configMapRef: + name: {{ $fullName }} + env: + {{- with .Values.bitwardenrs.admin }} + {{- if and .enabled (not .disableAdminToken) }} + - name: ADMIN_TOKEN + valueFrom: + secretKeyRef: + {{- if .existingSecret.enabled }} + name: {{ .existingSecret.name | quote }} + key: {{ .existingSecret.tokenKey | quote }} + {{- else }} + name: {{ $fullName }} + key: admin-token + {{- end }} + {{- end }} + {{- end }} + {{- with .Values.bitwardenrs.smtp }} + {{- if eq .enabled true }} + {{- if and .existingSecret.enabled (not .user) }} + - name: SMTP_USERNAME + valueFrom: + secretKeyRef: + name: {{ .existingSecret.name | quote }} + key: {{ .existingSecret.userKey | quote }} + - name: SMTP_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .existingSecret.name | quote }} + key: {{ .existingSecret.passwordKey | quote }} + {{- end }} + {{- end }} + {{- end }} + ports: + - name: http + containerPort: 80 + protocol: TCP + {{- if .Values.bitwardenrs.websockets.enabled }} + - name: websocket + containerPort: {{ .Values.bitwardenrs.websockets.port }} + protocol: TCP + {{- end }} + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + {{- with .Values.resources }} + resources: + {{- toYaml . | nindent 12 }} + {{- end }} + volumeMounts: + - name: {{ include "bitwardenrs.fullname" . }} + mountPath: /data + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + volumes: + - name: {{ include "bitwardenrs.fullname" . }} + {{- if .Values.persistence.enabled }} + persistentVolumeClaim: + claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim | quote }}{{- else }}{{ include "bitwardenrs.fullname" . }}{{- end }} + {{- else }} + emptyDir: {} + {{- end }} + {{- end }} \ No newline at end of file diff --git a/charts/bitwardenrs/templates/tests/test-connection.yaml b/charts/bitwardenrs/templates/tests/test-connection.yaml new file mode 100644 index 00000000..8e4ad525 --- /dev/null +++ b/charts/bitwardenrs/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "bitwardenrs.fullname" . }}-test-connection" + labels: + {{- include "bitwardenrs.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test-success +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "bitwardenrs.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/charts/bitwardenrs/values.yaml b/charts/bitwardenrs/values.yaml new file mode 100644 index 00000000..b32396a3 --- /dev/null +++ b/charts/bitwardenrs/values.yaml @@ -0,0 +1,132 @@ +# Default values for bitwardenrs. + +replicaCount: 1 + +image: + repository: bitwardenrs/server + pullPolicy: IfNotPresent + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +bitwardenrs: + domain: "" + signupsAllowed: false + websockets: + enabled: true + port: 3012 + admin: + enabled: true + disableAdminToken: false + existingSecret: + enabled: false + name: "" + tokenKey: "" + # Enable SMTP. https://github.com/dani-garcia/bitwarden_rs/wiki/SMTP-configuration + smtp: + enabled: false + # SMTP hostname, required if SMTP is enabled + host: "" + # SMTP sender e-mail address, required if SMTP is enabled + from: "" + # SMTP sender name, defaults to 'Bitwarden_RS' + fromName: "" + # Enable SSL connection + ssl: true + # SMTP port + port: 587 + # SMTP username + user: "" + # SMTP password. Required is user is specified, ignored if no user provided + password: "" + # Use existing secret for SMTP authentication + existingSecret: + enabled: false + name: "" + userKey: "" + passwordKey: "" + +env: {} + +persistence: + type: statefulset + enabled: false + size: 1Gi + accessMode: ReadWriteOnce + ## Persistent Volume storage class + # storageClass: "-" + ## Use existing Persistent Volume Claim + # existingClaim: + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + ## Provide any additional annotations which may be required. This can be used to + ## set the LoadBalancer service type to internal only. + ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer + ## + annotations: {} + labels: {} + additionalSpec: {} + +ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: [] + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {}