apiVersion: apps/v1
kind: Deployment
metadata:
    name: mysql-server
spec:                            # spec do deployment
    replicas: 1
    selector:                    # seletor utilizado para criar o service
        matchLabels:
          app: mysql-server
          tier: db
    template:                    # referente ao pod
        metadata:
            labels:
              app: mysql-server
              tier: db
        spec:                    # spec do pod
            containers:
            - image: mysql:5.7
              name: mysql-server
              args:
                - "--ignore-db-dir=lost+found"

              env:
              - name: MYSQL_ROOT_PASSWORD
                valueFrom:       # kubectl create secret generic mysql-pass --from-literal=password='a1s2d3f4'
                  secretKeyRef:
                    name: mysql-pass
                    key: password

              ports:
              - containerPort: 3306

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

            volumes:
              - name: mysql-persistent-storage
                persistentVolumeClaim:
                  claimName: mysql-pv-claim