apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql
spec:
  selector:
    matchLabels:
      app: mysql
  template:
    metadata:
      labels:
        app: mysql
    spec:
      containers:
        - name: mysql
          image: mysql:5.7
          imagePullPolicy: IfNotPresent
          env:
            - name: MYSQL_ROOT_PASSWORD
              value: 'root'
          volumeMounts:
            - mountPath: /etc/my.cnf
              name: mysql-config
              subPath: mysql/my.cnf
            - mountPath: /var/lib/mysql
              name: mysql-data
      volumes:
        - name: mysql-config
          configMap:
            name: mysql-config
            items:
              - key: my.cnf
                path: mysql/my.cnf
        - name: mysql-data
          persistentVolumeClaim:
            claimName: mysql-pvc