---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mysql
  labels:
    app: mysql
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mysql
  template:
    metadata:
      labels:
        app: mysql
    spec:
      containers:
        - name: database
          image: mysql:8.0
          # resources:
          #   requests:
          #     memory: 225Mi
          # livenessProbe:
          #   tcpSocket:
          #     port: 3306
          ports:
            - containerPort: 3306
          env:
            - name: MYSQL_ROOT_PASSWORD
              value: "2!0r!!B2yrB0an!"
            - name: MYSQL_DATABASE
              value: "default"
            - name: MYSQL_USER
              value: "amin"
            - name: MYSQL_PASSWORD
              value: "amin!amin56"
          volumeMounts:
            - name: mysql-config-volume
              mountPath: /etc/mysql/conf.d/default_auth.cnf
              subPath: default_auth
            - name: mysql-data
              mountPath: /var/lib/mysql
              subPath: mysql
      volumes:
        - name: mysql-config-volume
          configMap:
            name: mysql-config
  volumeClaimTemplates:
    - metadata:
        name: mysql-data
      spec:
        accessModes:
          - ReadWriteOnce
        resources:
          requests:
            storage: 20Gi
        storageClassName: do-block-storage
  serviceName: mysql

