helm-charts/grampsweb/templates/deployment.yaml

135 lines
4.5 KiB
YAML

apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "grampsweb.fullname" . }}
labels:
{{- include "grampsweb.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "grampsweb.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "grampsweb.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "grampsweb.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag | default (printf "v%s" .Chart.AppVersion) }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- sh
- -c
- |-
set -e
# create random flask secret key
if [ ! -s /app/secret/secret ]
then
mkdir -p /app/secret
python3 -c "import secrets;print(secrets.token_urlsafe(32))" | tr -d "\n" > /app/secret/secret
fi
# use the secret key if none is set (will be overridden by config file if present)
if [ -z "$GRAMPSWEB_SECRET_KEY" ]
then
export GRAMPSWEB_SECRET_KEY=$(cat /app/secret/secret)
fi
# Run migrations for user database, if any
cd /app/src/
python3 -m gramps_webapi --config /app/config/config.cfg user migrate
cd /app/
gunicorn -w ${GUNICORN_NUM_WORKERS:-8} -b 0.0.0.0:5000 gramps_webapi.wsgi:app --timeout 120 --limit-request-line 8190
envFrom:
- secretRef:
name: {{ include "grampsweb.fullname" . }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
# gramps_users
- name: "data"
mountPath: "/app/users"
subPath: "app/users"
# gramps_index
- name: "data"
mountPath: "/app/indexdir"
subPath: "app/indexdir"
# gramps_thumb_cache
- name: "data"
mountPath: "/app/thumbnail_cache"
subPath: "app/thumbnail_cache"
# gramps_secret
- name: "data"
mountPath: "/app/secret"
subPath: "app/secret"
# gramps_db
- name: "data"
mountPath: "/root/.gramps/grampsdb"
subPath: "root/.gramps/grampsdb"
# gramps_media
- name: "data"
mountPath: "/app/media"
subPath: "app/media"
{{- with .Values.volumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
volumes:
- name: "data"
{{- if .Values.persistence.hostPath }}
hostPath:
type: Directory
path: {{ .Values.persistence.hostPath | quote }}
{{- else if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ template "grampsweb.fullname" . }}{{- end }}
{{- else }}
emptyDir: {}
{{- end }}
{{- with .Values.volumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}