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