Skip to content
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
24 changes: 24 additions & 0 deletions charts/rauthy/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: rauthy
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "latest"
28 changes: 28 additions & 0 deletions charts/rauthy/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "rauthy.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 its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "rauthy.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "rauthy.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 "rauthy.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
{{ if .Release.IsInstall }}
Extract your secrets from the "{{ (include "rauthy.fullname" .) }}-config" secret in the "{{.Release.Namespace}}" namespace to extract secrets.

$ (kubectl get -n "{{.Release.Namespace}}" secret "{{ (include "rauthy.fullname" .) }}-config" \
--output=template --template='{{`{{`}} index .data "config.toml" {{`}}`}}' \
| base64 -d && echo )

{{- end }}
10 changes: 10 additions & 0 deletions charts/rauthy/templates/_config_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- define "rauthy.hostnameByIndex" }}
{{- $ := (index . 0) }}
{{- $i := (index . 1) }}
{{- printf "%s-%d.%s-headless.%s" (include "rauthy.fullname" $) ($i) (include "rauthy.fullname" $) ($.Release.Namespace) }}
{{- end }}

{{- define "rauthy.hostRaftSyncPortsByIndex" }}
{{- $ := (index . 0) }}
{{- include "rauthy.hostnameByIndex" . }}:{{ $.Values.service.hiqliteRaftPort }} {{ include "rauthy.hostnameByIndex" . }}:{{ $.Values.service.hiqliteAPIPort }}
{{- end }}
73 changes: 73 additions & 0 deletions charts/rauthy/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "rauthy.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 "rauthy.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 "rauthy.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "rauthy.labels" -}}
helm.sh/chart: {{ include "rauthy.chart" . }}
{{ include "rauthy.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Config secret name
*/}}
{{- define "rauthy.configSecretName" -}}
{{- if .Values.configSecretNameOverride }}
{{ .Values.configSecretNameOverride }}
{{- else }}
{{- default (include "rauthy.fullname" .) .Values.serviceAccount.name }}-config
{{- end }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "rauthy.selectorLabels" -}}
app.kubernetes.io/name: {{ include "rauthy.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "rauthy.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "rauthy.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
98 changes: 98 additions & 0 deletions charts/rauthy/templates/configsecret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{{- if .Values.config.enable }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "rauthy.fullname" . }}-config
namespace: {{ .Release.Namespace }}
type: Opaque
stringData:
config.toml: |-
{{ with .Values.config.bootstrap -}}
[bootstrap]
admin_email="{{ $.Values.adminEmail }}"
password_plain="{{ .password_plain }}"
{{ end -}}

[cluster]
node_id_from="k8s"
node_id=1
nodes= [
{{- range $i := (until (.Values.replicaCount | int)) }}
"{{ add $i 1}} {{ include "rauthy.hostRaftSyncPortsByIndex" (list $ $i) }}",
{{- end }}
]
secret_raft=
{{- with .Values.config.cluster.secret_raft -}}
"{{ . }}"
{{- else -}}
"{{ randAlphaNum 48 }}"
{{- end }}
secret_api=
{{- with .Values.config.cluster.secret_api -}}
"{{ . }}"
{{- else -}}
"{{ randAlphaNum 48 }}"
{{- end }}

[email]
rauthy_admin_email="{{ .Values.adminEmail }}"
smtp_url="{{ .Values.config.email.smtp_host }}"
smtp_port={{ .Values.config.email.smtp_port }}
danger_insecure={{ .Values.config.email.danger_insecure }}

[encryption]
{{- with .Values.config.encryption.keys }}
{{- range . }}
keys=[
"{{ . }}",
]
key_active="{{ $.Values.config.encryption.key_active }}"
{{- end }}
{{- else }}
{{- $key_id := ( printf "Auto%s" ( now | date "20060102T150405" ) ) }}
keys=[
"{{ $key_id }}/{{ randBytes 32 }}",
]
key_active="{{ $key_id }}"
{{- end }}

[hashing]
argon2_m_cost=131072
argon2_t_cost=4
argon2_p_cost=8
max_hash_threads=2

[mfa]
admin_force_mfa = false

[server]
port_http={{ .Values.config.server.port_http }}
port_https={{ .Values.config.server.port_https }}
{{- if .Values.config.server.port_https }}
scheme="http_https"
{{- else }}
scheme="http"
{{- end }}
{{- with index .Values.ingress.hosts }}
pub_url="{{ (first .).host }}"
{{- end }}
proxy_mode=true
trusted_proxies=[
{{- range .Values.config.server.trusted_proxies }}
"{{ . }}",
{{- end }}
]
swagger_ui_enable={{ .Values.config.server.swagger_enable }}

[[templates]]
lang="en"
typ="password_new"

[tls]
cert_path="tls/cert-chain.pem"
key_path="tls/key.pem"

[webauthn]
rp_id="{{ .Values.webauthn.rp_id }}"
rp_origin="{{ .Values.webauthn.rp_origin }}"
{{- end }}
33 changes: 33 additions & 0 deletions charts/rauthy/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "rauthy.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "rauthy.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "rauthy.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
38 changes: 38 additions & 0 deletions charts/rauthy/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{{- if .Values.ingress.enabled -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "rauthy.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "rauthy.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- with .Values.ingress.className }}
ingressClassName: {{ . }}
{{- end }}
{{- if .Values.ingress.hosts }}
tls:
{{- range .Values.ingress.hosts }}
- hosts:
- {{ .host | quote }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: {{ include "rauthy.fullname" $ }}
port:
name: http
{{- end }}
{{- end }}
20 changes: 20 additions & 0 deletions charts/rauthy/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "rauthy.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "rauthy.labels" . | nindent 4 }}
spec:
type: ClusterIP
ports:
- port: {{ .Values.config.server.port_http }}
targetPort: http
protocol: TCP
name: http
- port: {{ .Values.config.server.port_https }}
targetPort: https
protocol: TCP
name: https
selector:
{{- include "rauthy.selectorLabels" . | nindent 4 }}
14 changes: 14 additions & 0 deletions charts/rauthy/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "rauthy.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "rauthy.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}
Loading