apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
  name: java2days-mysql-delployment
  namespace: java2days
spec:
  selector:
    matchLabels:
      app: java2days-mysql
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: java2days-mysql
    spec:
      containers:
        - image: mysql:5.6
          name: mysql
          env:
            - name: MYSQL_ROOT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: java2days-mysql-credentials
                  key: password
          ports:
            - containerPort: 3306
              name: mysql
          volumeMounts:
            - name: mysql-persistent-storage
              mountPath: /var/lib/mysql
      volumes:
        - name: mysql-persistent-storage
          persistentVolumeClaim:
            claimName: java2days-mysql-pvc
