[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
This commit is contained in:
Nicholas St. Germain 2020-08-16 19:53:28 -05:00 committed by GitHub
parent 8c201defc6
commit df13abf94a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 737 additions and 0 deletions

View File

@ -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/

View File

@ -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

View File

@ -0,0 +1,4 @@
approvers:
- DirtyCajunRice
reviewers:
- DirtyCajunRice

View File

@ -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
```

View File

@ -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 }}

View File

@ -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 }}

View File

@ -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 }}

View File

@ -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 }}

View File

@ -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 }}

View File

@ -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 }}

View File

@ -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 -}}

View File

@ -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 }}

View File

@ -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 }}

View File

@ -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 }}

View File

@ -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 }}

View File

@ -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

View File

@ -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: {}