eikek/docspell#2502 Started work on a helm chart for docspell including postgres and solr.

This commit is contained in:
2024-02-16 11:50:46 +01:00
parent d107343303
commit 8b0dfaedc1
26 changed files with 1566 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
{{/*
Common labels
*/}}
{{- define "solr.labels" -}}
helm.sh/chart: {{ include "docspell.chart" . }}
app: {{ include "docspell.name" . }}-solr
{{ include "solr.selectorLabels" . }}
app.kubernetes.io/version: {{ .Values.solr.image.tag | quote }}
version: {{ .Values.solr.image.tag | quote }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "solr.selectorLabels" -}}
app.kubernetes.io/name: {{ include "docspell.name" . }}-solr
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create solr image name and tag used by the deployment
*/}}
{{- define "solr.image" -}}
{{- $registry := .Values.global.imageRegistry | default .Values.solr.image.registry -}}
{{- $repository := .Values.solr.image.repository -}}
{{- $separator := ":" -}}
{{- $tag := .Values.solr.image.tag | default .Chart.AppVersion -}}
{{- if $registry -}}
{{- printf "%s/%s%s%s" $registry $repository $separator $tag -}}
{{- else -}}
{{- printf "%s%s%s" $repository $separator $tag -}}
{{- end -}}
{{- end -}}
{{/*
Connection URL
*/}}
{{- define "solr.url" -}}
{{- $port := .Values.solr.service.port | toString -}}
{{- $service := printf "%s-solr" (include "docspell.fullname" .) -}}
{{- printf "http://%s:%s/solr/docspell" $service $port -}}
{{- end }}
{{/*
Storage Class
*/}}
{{- define "solr.persistence.storageClass" -}}
{{- $storageClass := .Values.solr.persistence.storageClass | default .Values.global.storageClass -}}
{{- if $storageClass -}}
storageClassName: {{ $storageClass | quote }}
{{- end -}}
{{- end -}}

View File

@@ -0,0 +1,21 @@
{{- if and .Values.solr.enabled .Values.solr.persistence.enabled -}}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Values.solr.persistence.claimName }}
namespace: {{ $.Release.Namespace }}
annotations:
{{ .Values.solr.persistence.annotations | toYaml | indent 4}}
spec:
accessModes:
{{- .Values.solr.persistence.accessModes | toYaml | nindent 4 }}
volumeMode: Filesystem
{{- include "solr.persistence.storageClass" . | nindent 2 }}
{{- with .Values.solr.persistence.volumeName }}
volumeName: {{ . }}
{{- end }}
resources:
requests:
storage: {{ .Values.solr.persistence.size }}
{{- end }}

View File

@@ -0,0 +1,22 @@
{{- if .Values.solr.enabled -}}
apiVersion: v1
kind: Service
metadata:
name: {{ include "docspell.fullname" . }}-solr
labels:
{{- include "solr.labels" . | nindent 4 }}
{{- if .Values.solr.service.labels }}
{{- toYaml .Values.solr.serivce.labels | nindent 4 }}
{{- end }}
annotations:
{{- toYaml .Values.solr.service.annotations | nindent 4 }}
spec:
type: {{ .Values.solr.service.type }}
ports:
- port: {{ .Values.solr.service.port }}
targetPort: {{ .Values.solr.service.targetPort | default .Values.solr.service.port }}
protocol: TCP
name: solr
selector:
{{- include "solr.selectorLabels" . | nindent 4 }}
{{- end -}}

View File

@@ -0,0 +1,98 @@
{{- if .Values.solr.enabled -}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "docspell.fullname" . }}-solr
annotations:
{{- if .Values.solr.statefulSet.annotations }}
{{- toYaml .Values.solr.statefulSet.annotations | nindent 4 }}
{{- end }}
labels:
{{- include "solr.labels" . | nindent 4 }}
spec:
replicas: 1
selector:
matchLabels:
{{- include "solr.selectorLabels" . | nindent 6 }}
{{- if .Values.solr.statefulSet.labels }}
{{- toYaml .Values.solr.statefulSet.labels | nindent 6 }}
{{- end }}
serviceName: {{ include "docspell.fullname" . }}-solr
template:
metadata:
annotations:
{{- with .Values.solr.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "solr.labels" . | nindent 8 }}
{{- if .Values.solr.statefulSet.labels }}
{{- toYaml .Values.solr.statefulSet.labels | nindent 8 }}
{{- end }}
app: solr
spec:
{{- if (or .Values.serviceAccount.create .Values.serviceAccount.name) }}
serviceAccontName: {{ include "docspell.serviceAccountName" . }}
{{- end }}
initContainers:
- name: solr-fix-permissions
image: busybox
command:
- sh
- -c
- chown -R 8983:8983 /var/solr
volumeMounts:
- name: solr-data
mountPath: /var/solr
resources:
{{- toYaml .Values.solr.initContainers.resources | nindent 12 }}
terminationGracePeriodSeconds: {{ .Values.solr.statefulSet.terminationGracePeriodSeconds }}
containers:
- name: solr
image: "{{ include "solr.image" . }}"
imagePullPolicy: {{ .Values.solr.image.pullPolicy }}
env:
- name: SOLR_OPTS
value: -Dsolr.modules=analysis-extras
command:
- docker-entrypoint.sh
- solr-precreate
- docspell
ports:
- containerPort: {{ .Values.solr.service.port }}
name: solr
{{- if .Values.solr.livenessProbe.enabled }}
livenessProbe:
{{- toYaml (omit .Values.solr.livenessProbe "enabled") | nindent 10 }}
{{- end }}
{{- if .Values.solr.readinessProbe.enabled }}
readinessProbe:
{{- toYaml (omit .Values.solr.readinessProbe "enabled") | nindent 10 }}
{{- end }}
resources:
{{- toYaml .Values.solr.resources | nindent 10 }}
volumeMounts:
- name: solr-data
mountPath: /var/solr
{{- with .Values.global.hostAliases }}
hostAliases:
{{- toYaml . | nindent 6 }}
{{- with .Values.solr.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- with .Values.solr.affinity }}
affinity:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- end }}
volumes:
{{- if .Values.solr.persistence.enabled }}
- name: solr-data
persistentVolumeClaim:
claimName: {{ .Values.solr.persistence.claimName }}
{{- else if not .Values.solr.persistence.enabled }}
- name: solr-data
emptyDir: {}
{{- end }}
{{- end -}}