Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add first bookstack chart #37

Merged
merged 2 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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/bookstack/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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/
tests/
14 changes: 14 additions & 0 deletions charts/bookstack/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v2
name: bookstack
description: A Helm chart for running bookstack on Kubernetes
type: application
maintainers:
- name: Element SRE Team

# This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
version: "0.1.0"

# Track the appVersion based on the image:
# renovate: image=ghcr.io/linuxserver/bookstack
appVersion: "version-v23.02.1"
62 changes: 62 additions & 0 deletions charts/bookstack/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "bookstack.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 "bookstack.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 "bookstack.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "bookstack.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "bookstack.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
216 changes: 216 additions & 0 deletions charts/bookstack/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "bookstack.fullname" . }}
labels:
{{- include "bookstack.labels" . | nindent 4 }}
spec:
replicas: 1
{{- if .Values.revisionHistoryLimit }}
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
{{- end }}
selector:
matchLabels:
{{- include "bookstack.selectorLabels" . | nindent 6 }}
{{- with .Values.strategy }}
strategy:
{{- toYaml . | nindent 4 }}
{{- end }}
template:
metadata:
annotations:
checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "bookstack.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "bookstack.serviceAccountName" . }}
{{- with .Values.podSecurityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
{{- with .Values.securityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 80
protocol: TCP
envFrom:
- secretRef:
name: {{ include "bookstack.fullname" . }}
env:
{{- if .Values.settings.url }}
- name: APP_URL
value: {{ .Values.settings.url | quote }}
{{- end }}
{{- if .Values.settings.debug }}
- name: APP_DEBUG
value: {{ .Values.settings.debug | quote }}
{{- end }}
{{- if .Values.settings.sessionLifetime }}
- name: SESSION_LIFETIME
value: {{ .Values.settings.sessionLifetime | quote }}
{{- end }}
{{- if .Values.settings.tz }}
- name: TZ
value: {{ .Values.settings.tz | quote }}
{{- end }}
{{- if .Values.settings.authSaml2.enabled }}
- name: AUTH_METHOD
value: "saml2"
{{- with .Values.settings.authSaml2 }}
- name: SAML2_AUTOLOAD_METADATA
value: {{ .autoloadMetadata | quote }}
- name: SAML2_DISPLAY_NAME_ATTRIBUTES
value: {{ .displayNameAttribute | quote }}
- name: SAML2_EMAIL_ATTRIBUTE
value: {{ .emailAttribute | quote }}
- name: SAML2_EXTERNAL_ID_ATTRIBUTE
value: {{ .externalIdAttribute | quote }}
- name: SAML2_GROUP_ATTRIBUTE
value: {{ .groupAttribute | quote }}
- name: SAML2_IDP_AUTHNCONTEXT
value: {{ .idpAuthnContent | quote }}
- name: SAML2_IDP_ENTITYID
value: {{ .idpEntityId | quote }}
- name: SAML2_NAME
value: {{ .name | quote }}
- name: SAML2_REMOVE_FROM_GROUPS
value: {{ .removeFromGroups | quote }}
- name: SAML2_USER_TO_GROUPS
value: {{ .userToGroups | quote }}
{{- end }}
{{- end }}
{{- if .Values.settings.mail.enabled }}
{{- with .Values.settings.mail }}
- name: MAIL_DRIVER
value: {{ .transport | quote }}
- name: MAIL_ENCRYPTION
value: {{ .encryption | quote }}
- name: MAIL_FROM
value: {{ .from | quote }}
- name: MAIL_FROM_NAME
value: {{ .displayName | quote }}
- name: MAIL_HOST
value: {{ .host | quote }}
- name: MAIL_PORT
value: {{ .port | quote }}
{{- end }}
{{- end }}
{{- with .Values.env }}
{{- toYaml . | nindent 12 }}
{{- end }}

{{- if .Values.customStartupProbe }}
startupProbe:
{{- toYaml .Values.customStartupProbe | nindent 12 }}
{{- else }}
{{- if .Values.startupProbe.enabled }}
startupProbe:
httpGet:
path: /
port: http
httpHeaders:
- name: Host
value: localhost:2368
{{- with .Values.startupProbe }}
initialDelaySeconds: {{ .initialDelaySeconds }}
timeoutSeconds: {{ .timeoutSeconds }}
failureThreshold: {{ .failureThreshold }}
successThreshold: {{ .successThreshold }}
periodSeconds: {{ .periodSeconds }}
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.customLivenessProbe }}
livenessProbe:
{{- toYaml .Values.customLivenessProbe | nindent 12 }}
{{- else }}
{{- if .Values.livenessProbe.enabled }}
livenessProbe:
httpGet:
path: /
port: http
httpHeaders:
- name: Host
value: localhost:2368
{{- with .Values.livenessProbe }}
initialDelaySeconds: {{ .initialDelaySeconds }}
timeoutSeconds: {{ .timeoutSeconds }}
failureThreshold: {{ .failureThreshold }}
successThreshold: {{ .successThreshold }}
periodSeconds: {{ .periodSeconds }}
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.customReadinessProbe }}
readinessProbe:
{{- toYaml .Values.customReadinessProbe | nindent 12 }}
{{- else }}
{{- if .Values.readinessProbe.enabled }}
readinessProbe:
httpGet:
path: /
port: http
httpHeaders:
- name: Host
value: localhost:2368
{{- with .Values.readinessProbe }}
initialDelaySeconds: {{ .initialDelaySeconds }}
timeoutSeconds: {{ .timeoutSeconds }}
failureThreshold: {{ .failureThreshold }}
successThreshold: {{ .successThreshold }}
periodSeconds: {{ .periodSeconds }}
{{- end }}
{{- end }}
{{- end }}
{{- with .Values.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if .Values.args }}
args:
{{- range .Values.args }}
- {{ . }}
{{- end }}
{{- end }}
volumeMounts:
- mountPath: /config
name: bookstack-vol
{{- 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: bookstack-vol
{{- if .Values.storage.persistentVolumeClaimName }}
persistentVolumeClaim:
claimName: {{ .Values.storage.persistentVolumeClaimName }}
{{- else }}
{{- if .Values.storage.requestedSize }}
persistentVolumeClaim:
claimName: {{ include "bookstack.fullname" . }}
{{- else }}
emptyDir: {}
{{- end }}
{{- end }}
55 changes: 55 additions & 0 deletions charts/bookstack/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "bookstack.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
{{- end }}
{{- end }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "bookstack.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- 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: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
Loading