apiVersion: apps/v1
kind: Deployment
metadata:
  name: mariadb
spec:
  replicas: 1
  revisionHistoryLimit: 1
  selector:
    matchLabels:
      name: mariadb
  template:
    metadata:
      labels:
        name: mariadb
    spec:
      hostNetwork: false
      hostPID: false
      hostIPC: false
      containers:
      - image: mariadb:latest
        securityContext:
          privileged: false
          readOnlyRootFilesystem: false
          allowPrivilegeEscalation: false
          runAsNonRoot: false
          runAsUser: 0
          capabilities:
            add: ["SETFCAP", "SETGID", "SETUID", "DAC_OVERRIDE", "FOWNER", "CHOWN"]
            drop: ["ALL"]
        name: mariadb
        resources:
          requests:
            cpu: "0"
          limits:
            memory: "1G"
            cpu: "1"
        env:
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mysql-password
              key: mysql.key
        ports:
        - containerPort: 3306
          name: mariadb
        readinessProbe:
            tcpSocket:
              port: 3306
        livenessProbe:
            exec:
              command: ["mysqladmin", "ping", "-h", "127.0.0.1", "-P", "3306", "-u", "root",  "-p${MYSQL_ROOT_PASSWORD}", "--skip-ssl"]
            initialDelaySeconds: 120
            periodSeconds: 120
            timeoutSeconds: 10
            failureThreshold: 4
        volumeMounts:
        - name: mariadb-data
          mountPath: /var/lib/mysql
        - name: mariadb-tmp
          mountPath: /tmp
      volumes:
      - name: mariadb-data
        persistentVolumeClaim:
          claimName: mariadb-data-claim
      - name: mariadb-tmp
        persistentVolumeClaim:
          claimName: mariadb-tmp-claim