---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nextcloud-mariadb
  namespace: nextcloud
  annotations:
    kustomize.toolkit.fluxcd.io/substitute: disabled
    reloader.stakater.com/auto: "true"
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nextcloud-mariadb
  strategy:
    type: Recreate
  template:
    metadata:
      annotations:
        k8up.io/backupcommand: /bin/bash -c 'mysqldump -uroot -p"${MYSQL_ROOT_PASSWORD}" --all-databases'
      labels:
        app: nextcloud-mariadb
    spec:
      containers:
        - name: nextcloud-mariadb
          image: mariadb:10.6.4
          args:
            - --innodb-read-only-compressed=OFF
          envFrom:
            - secretRef:
                name: nextcloud-mariadb
          env:
            - name: TZ
              value: Europe/Zurich
          ports:
            - containerPort: 3306
          volumeMounts:
            - mountPath: /var/lib/mysql
              name: data
          livenessProbe:
            exec:
              command:
                - /bin/bash
                - -ec
                - mysqladmin status -uroot -p"${MYSQL_ROOT_PASSWORD}"
            failureThreshold: 2
            periodSeconds: 30
            timeoutSeconds: 5
          resources: {}
      restartPolicy: Always
      automountServiceAccountToken: false
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: nextcloud-mariadb-data
