apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mariadb
  namespace: photoprism
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 20Gi  # Match or be less than the PV's capacity
  volumeName: mariadb-db-pv  # Bind explicitly to the PV created above
  storageClassName: nfs

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mariadb
  namespace: photoprism
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mariadb
  template:
    metadata:
      labels:
        app: mariadb
    spec:
      containers:
        - name: mariadb
          image: mariadb:10.11
          env:
            - name: MYSQL_ROOT_PASSWORD
              value: photoprism
            - name: MYSQL_DATABASE
              value: photoprism
            - name: MYSQL_USER
              value: photoprism
            - name: MYSQL_PASSWORD
              value: photoprism
          volumeMounts:
            - mountPath: /var/lib/mysql
              name: mariadb
          securityContext:
            runAsUser: 1001
            runAsGroup: 1000
 #           fsGroup: 2000
      volumes:
        - name: mariadb
          persistentVolumeClaim:
            claimName: mariadb
---
apiVersion: v1
kind: Service
metadata:
  name: mariadb
  namespace: photoprism
spec:
  type: ClusterIP
  selector:
    app: mariadb
  ports:
    - port: 3306
