apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mysql-db
spec:
  serviceName: "mysql-headless"
  replicas: 1
  selector:
    matchLabels:
      app: mysqldb
  template:
    metadata:
      labels:
        app: mysqldb
      annotations:
        version/config : "202201152146"
    spec:
      nodeName: minikube
      volumes: 
        - name: mysql-storage
          persistentVolumeClaim:
            claimName: mysql-pvc
        - name: mysql-config
          configMap:
            name: mysql-config
      containers:
      - name: mysql-db
        image: mysql:5.7.20
        env:
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mysql-secret
              key: rootPassword
        - name: MYSQL_DATABASE
          value: demo
        ports:
        - containerPort: 3306
          name: mysql-port
        volumeMounts:
          - mountPath: /var/lib/mysql
            name: mysql-storage
          - mountPath: /etc/my.cnf
            subPath: my.cnf
            name: mysql-config