apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mysql
spec:
  selector:
    matchLabels:
      app: mysql
  serviceName: mysql
  replicas: 1
  template:
    metadata:
      labels:
        app: mysql
    spec:
      terminationGracePeriodSeconds: 10
      containers:
      - name: mysql
        image: moech/mysql:5.7.33
        env:
        - name: MYSQL_AUTHENTICATION_PLUGIN
          value: "mysql_native_password"
        - name: ALLOW_EMPTY_PASSWORD
          valueFrom:
            configMapKeyRef:
              name: mysql-config
              key: ALLOW_EMPTY_PASSWORD
        - name: MYSQL_DATABASE
          valueFrom:
            configMapKeyRef:
              name: mysql-config
              key: MYSQL_DATABASE
        envFrom:
        - secretRef:
            name: mysql-user
        ports:
        - containerPort: 3306
          protocol: TCP
        livenessProbe:
          exec:
            command:
            - /opt/bitnami/scripts/mysql/healthcheck.sh
          failureThreshold: 5
          initialDelaySeconds: 15
          timeoutSeconds: 5
        volumeMounts:
        - mountPath: /etc/localtime
          name: host-time
          readOnly: true
        - mountPath: /bitnami/mysql/data
          name: data
        - mountPath: "/opt/bitnami/mysql/conf/my_custom.cnf"
          subPath: "my_custom.cnf"
          name: mycnf
          readOnly: true
      nodeSelector:
        NodeType: Application
      restartPolicy: Always
      volumes:
      - hostPath:
          path: /etc/localtime
          type: ""
        name: host-time
      - configMap:
          name: mysql-config
        name: mycnf
  volumeClaimTemplates:
  - metadata:
      name: data
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 60Gi
