apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql-deployment
  labels:
    name: mysql-deployment
    app: spring3hibernate-app 
spec:
  selector:
    matchLabels:
      app: mysql-deployment
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: mysql-deployment
    spec:
      containers:
      - image: rsharm49/mysql_tree_git
        name: mysql
        env:
          # Use secret in real usage
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
              secretKeyRef:
                name: mysql-secret
                key: MYSQL_ROOT_PASSWORD
        - name: MYSQL_DATABASE
          valueFrom:
              secretKeyRef:
                name: mysql-secret
                key: MYSQL_DATABASE
        - name: MYSQL_USER
          valueFrom:
              secretKeyRef:
                name: mysql-secret
                key: MYSQL_USER
        - name: MYSQL_PASSWORD
          valueFrom:
              secretKeyRef:
                name: mysql-secret
                key: MYSQL_PASSWORD          
        ports:
        - containerPort: 3306
          name: mysql
        volumeMounts:
        - name: mysql-persistent-storage
          mountPath: /var/lib/mysql
      volumes:
      - name: mysql-persistent-storage
        persistentVolumeClaim:
          claimName: mysql-pv-claim
