apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
  name: mysql
  labels:
    app: mysql
spec:
  selector:
    matchLabels:
      app: mysql
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: mysql
    spec:
      containers:
      # linux/arm64: https://hub.docker.com/layers/mysql/mysql-server/8.0.19-aarch64/images/sha256-5495664652ac1a8c78c8079bc838483732c12ef59a7f7dbed21adbade33fa1ea
      - image: mysql/mysql-server@sha256:5495664652ac1a8c78c8079bc838483732c12ef59a7f7dbed21adbade33fa1ea
        name: mysql
        env:
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mysql-pass
              key: password
        ports:
        - containerPort: 3306
          name: mysql
        volumeMounts:
        - name: mysql-persistent-storage
          mountPath: /var/lib/mysql
        - name: mysql-initdb
          mountPath: /docker-entrypoint-initdb.d
      volumes:
      - name: mysql-persistent-storage
        emptyDir: {}
      - name: mysql-initdb
        configMap:
          name: mysql-initdb-config
