apiVersion: apps/v1
kind: Deployment
metadata:
  name: nc-mysql
  labels:
    app: nc-mysql
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nc-mysql
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: nc-mysql
    spec:
      containers:
        - image: mysql:5.7
          args:
            - "--ignore-db-dir=lost+found"
          name: mysql
          env:
            - name: MYSQL_ROOT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: nc-mysql-secret
                  key: password
            - name: MYSQL_DATABASE
              valueFrom:
                secretKeyRef:
                  name: nc-mysql-secret
                  key: database
          ports:
            - containerPort: 3306
              name: mysql
          volumeMounts:
            - name: mysql-persistent-storage
              mountPath: /var/lib/mysql
      volumes:
        - name: mysql-persistent-storage
          persistentVolumeClaim:
            claimName: mysql-nc-pv-claim
