---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql
  namespace: blog
  labels:
    app: blog
spec:
  selector:
    matchLabels:
      app: blog
      tier: mysql
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: blog
        tier: mysql
    spec:
      containers:
      - image: mysql:8.0.27
        name: mysql
        env:
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: 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-pvc
