apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql-server
spec: # referente do deployment
  replicas: 1
  selector: #selector 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
              #  value: root
              valueFrom:
                secretKeyRef:
                  name: msql-pass
                  key: password

          ports:
            - containerPort: 3306

          volumeMounts: # monta o volume efetivamente
            - name: mysql-persistent-storage
              mountPath: /var/lib/mysql

      volumes: # definição do volume
        - name: mysql-persistent-storage
          persistentVolumeClaim:
            claimName: mysql-pv-claim
