apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql-dep
  namespace: shoppingportal
spec:
  selector:
    matchLabels:
      app: mysql
      version: v1
  template:
    metadata:
      labels:
        app: mysql
        version: v1
    spec:
      containers:
      - image: docker.io/mysql
        name: mysql-cntr
        env:
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mysecret
              key: password
        ports:
        - containerPort: 3306
        volumeMounts:
        - name: mysql-persistent-storage
          mountPath: /var/lib/mysql/
      volumes:
      - name: mysql-persistent-storage
        hostPath:
            path: /tmp/mysql/
       
