apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app.kubernetes.io/name: nextcloud
  name: nextcloud
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: nextcloud
  template:
    metadata:
      creationTimestamp: null
      labels:
        app.kubernetes.io/name: nextcloud
    spec:
      containers:
      - env:
        - name: MYSQL_HOST
          value: nextcloud-mysql-mariadb
        - name: MYSQL_DATABASE
          value: nextcloud
        - name: MYSQL_USER
          value: nextcloud
        - name: MYSQL_PASSWORD
          valueFrom:
            secretKeyRef:
              name: db-creds
              key: mariadb-password
        - name: NEXTCLOUD_ADMIN_USER
          valueFrom:
            secretKeyRef:
              key: nextcloud-username
              name: nextcloud
        - name: NEXTCLOUD_ADMIN_PASSWORD
          valueFrom:
            secretKeyRef:
              key: nextcloud-password
              name: nextcloud
        - name: NEXTCLOUD_TRUSTED_DOMAINS
          value: nextcloud.martyn.berlin
        - name: NEXTCLOUD_DATA_DIR
          value: /var/www/html/data
        image: nextcloud:27-apache
        imagePullPolicy: Always
        livenessProbe:
          failureThreshold: 3
          httpGet:
            httpHeaders:
            - name: Host
              value: nextcloud.martyn.berlin
            path: /status.php
            port: http
            scheme: HTTP
          initialDelaySeconds: 10
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 5
        name: nextcloud
        ports:
        - containerPort: 80
          name: http
          protocol: TCP
        readinessProbe:
          failureThreshold: 3
          httpGet:
            httpHeaders:
            - name: Host
              value: nextcloud.martyn.berlin
            path: /status.php
            port: http
            scheme: HTTP
          initialDelaySeconds: 10
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 5
        volumeMounts:
        - mountPath: /var/www/
          name: nextcloud-main
          subPath: root
        - mountPath: /var/www/html
          name: nextcloud-main
          subPath: html
        - mountPath: /var/www/html/data
          name: nextcloud-main
          subPath: data
        - mountPath: /var/www/html/config
          name: nextcloud-main
          subPath: config
        - mountPath: /var/www/html/custom_apps
          name: nextcloud-main
          subPath: custom_apps
        - mountPath: /var/www/tmp
          name: nextcloud-main
          subPath: tmp
        - mountPath: /var/www/html/themes
          name: nextcloud-main
          subPath: themes
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext:
        fsGroup: 33
      terminationGracePeriodSeconds: 30
      volumes:
      - name: nextcloud-main
        persistentVolumeClaim:
          claimName: nextcloud-nextcloud