apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: mysql
  labels:
    app: mysql
    project: mysql-test
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mysql
  template:
    metadata:
      labels:
        app: mysql
        project: mysql-test
    spec:
      containers:
      - name: database
        image: mysql:8.0.22
        env:
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mysql-secret
              key: rootpassword
        livenessProbe:
          tcpSocket:
            port: 3306
        ports:
          - containerPort: 3306
        #volume mount for the init sql script
        volumeMounts:
          - name: init-config
            mountPath: "/docker-entrypoint-initdb.d"
            readOnly: true
      volumes:
        - name: init-config
          configMap:
            name: mysql-configmap
            items:
              - key: "init.sql"
                path: "init.sql"
# no volume specification for ephemeral data