Helm chart to install nextcloud in Kubernetes.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
helm-nextcloud/templates/deployment.yaml

172 lines
6.1 KiB

---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "nextcloud.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
helm.sh/chart: {{ include "nextcloud.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/component: app
{{- if .Values.deploymentAnnotations }}
annotations:
{{ toYaml .Values.deploymentAnnotations | indent 4 }}
{{- end }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: app
template:
metadata:
name: {{ template "nextcloud.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: app
spec:
{{- if .Values.securityContext }}
securityContext:
{{- toYaml .Values.securityContext | nindent 8 }}
{{- end }}
{{- if and .Values.volumePermissions.enabled .Values.persistence.enabled }}
initContainers:
- name: init-chmod-data
image: "{{ .Values.volumePermissions.image.repository }}:{{ .Values.volumePermissions.image.tag }}"
imagePullPolicy: "{{ .Values.volumePermissions.image.pullPolicy }}"
resources:
{{ toYaml .Values.resources | indent 10 }}
command:
- sh
- -c
- |
mkdir -p {{ .Values.persistence.mountPath }}/data
chmod 700 {{ .Values.persistence.mountPath }}/data
find {{ .Values.persistence.mountPath }} -mindepth 1 -maxdepth 1 -not -name ".snapshot" -not -name "lost+found" | \
xargs chown -R {{ .Values.securityContext.runAsUser }}:{{ .Values.securityContext.fsGroup }}
securityContext:
runAsUser: {{ .Values.volumePermissions.securityContext.runAsUser }}
privileged: {{ .Values.volumePermissions.securityContext.privileged }}
volumeMounts:
- name: data
mountPath: {{ .Values.persistence.mountPath }}
{{- end }}
containers:
- name: {{ template "nextcloud.fullname" . }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
resources:
{{ toYaml .Values.resources | indent 10 }}
env:
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
key: password
{{- if .Values.postgresql.secretName }}
name: {{ .Values.postgresql.secretName }}
{{- else }}
name: postgres
{{- end }}
- name: POSTGRES_USER
valueFrom:
secretKeyRef:
key: username
{{- if .Values.postgresql.secretName }}
name: {{ .Values.postgresql.secretName }}
{{- else }}
name: postgres
{{- end }}
- name: POSTGRES_DB
valueFrom:
secretKeyRef:
key: database
{{- if .Values.postgresql.secretName }}
name: {{ .Values.postgresql.secretName }}
{{- else }}
name: postgres
{{- end }}
- name: NEXTCLOUD_ADMIN_USER
valueFrom:
secretKeyRef:
key: username
{{- if .Values.nextcloud.secretName }}
name: {{ .Values.nextcloud.secretName }}
{{- else }}
name: nextcloud
{{- end }}
- name: NEXTCLOUD_ADMIN_PASSWORD
valueFrom:
secretKeyRef:
key: password
{{- if .Values.nextcloud.secretName }}
name: {{ .Values.nextcloud.secretName }}
{{- else }}
name: nextcloud
{{- end }}
- name: NEXTCLOUD_DATA_DIR
value: {{ .Values.nextcloud.datadir }}
- name: NEXTCLOUD_TRUSTED_DOMAINS
value: {{ .Values.nextcloud.host }}
{{- if .Values.extraEnv }}
{{ tpl (toYaml .Values.extraEnv) $ | indent 8 }}
{{- end }}
ports:
- name: nextcloud
containerPort: 80
protocol: TCP
livenessProbe:
{{ toYaml .Values.livenessProbe | indent 12 }}
readinessProbe:
{{ toYaml .Values.readinessProbe | indent 12 }}
startupProbe:
{{ toYaml .Values.readinessProbe | indent 12 }}
volumeMounts:
{{- if .Values.persistence.enabled }}
- name: nextcloud
mountPath: {{ .Values.persistence.mountPath }}
{{- end }}
{{- range $key, $value := .Values.nextcloud.configs }}
- name: nextcloud-config
mountPath: /var/www/html/config/{{ $key }}
subPath: {{ $key }}
{{- end }}
{{- if .Values.nextcloud.configs }}
{{- range $key, $value := .Values.nextcloud.defaultConfigs }}
{{- if $value }}
- name: nextcloud-config
mountPath: /var/www/html/config/{{ $key }}
subPath: {{ $key }}
{{- end }}
{{- end }}
{{- end }}
volumes:
- name: nextcloud
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ template "nextcloud.fullname" . }}-nextcloud{{- end }}
{{- else }}
emptyDir: {}
{{- end }}
{{- if .Values.nextcloud.configs }}
- name: nextcloud-config
configMap:
name: {{ template "nextcloud.fullname" . }}-config
{{- end }}
{{- if .Values.nextcloud.phpConfigs }}
- name: nextcloud-phpconfig
configMap:
name: {{ template "nextcloud.fullname" . }}-phpconfig
{{- end }}
{{- if .Values.nextcloud.extraVolumes }}
{{ toYaml .Values.nextcloud.extraVolumes | indent 6 }}
{{- end }}
securityContext:
fsGroup: 33
{{- if .Values.securityContext }}
{{- with .Values.securityContext }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}