apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql-server-db
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mysql-server-db
      tier: db

  template:
    metadata:
      labels:
        app: mysql-server-db
        tier: db
    spec:
      containers:
      - name: mysql-server-db
        image: mysql:5.7
        args:
          - "--ignore-db-dir=lost+found"
        env:
          - name: MYSQL_ROOT_PASSWORD
            valueFrom:
              secretKeyRef:
                key: password
                name: mysql-pass
        ports:
        - containerPort: 3306

        volumeMounts:
        - name: mysql-persistent-storage
          mountPath: /var/lib/mysql

      volumes:
      - name: mysql-persistent-storage
        persistentVolumeClaim:
          claimName: mysql-pvc-db
