apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    component: db
  name: db
spec:
  selector:
    matchLabels:
      component: db
  replicas: 1
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        component: db
    spec:
      containers:
        - name: db
          image: mariadb:latest
          ports:
            - containerPort: 3306
          args:
            - --transaction-isolation=READ-COMMITTED
            - --binlog-format=ROW
            - --max-connections=1000
          env:
            - name: MYSQL_DATABASE
              valueFrom:
                secretKeyRef:
                  key: MYSQL_DATABASE
                  name: db-secrets
            - name: MYSQL_PASSWORD
              valueFrom:
                secretKeyRef:
                  key: MYSQL_PASSWORD
                  name: db-secrets
            - name: MYSQL_ROOT_PASSWORD
              valueFrom:
                secretKeyRef:
                  key: MYSQL_ROOT_PASSWORD
                  name: db-secrets
            - name: MYSQL_USER
              valueFrom:
                secretKeyRef:
                  key: MYSQL_USER
                  name: db-secrets
          volumeMounts:
            - mountPath: /var/lib/mysql
              name: db-persistent-storage
      restartPolicy: Always
      volumes:
        - name: db-persistent-storage
          persistentVolumeClaim:
            claimName: db-pvc