# Source: mysql/templates/primary/statefulset.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: db01-mysql
  labels:
    app.kubernetes.io/name: mysql
    helm.sh/chart: mysql-8.6.2
    app.kubernetes.io/instance: db01
    app.kubernetes.io/managed-by: konvert
    app.kubernetes.io/component: primary
  annotations:
    konvert.kumorilabs.io/generated-by: 'konvert'
    konvert.kumorilabs.io/chart: 'https://charts.bitnami.com/bitnami,mysql'
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: mysql
      app.kubernetes.io/instance: db01
      app.kubernetes.io/component: primary
  serviceName: db01-mysql
  updateStrategy:
    type: RollingUpdate
  template:
    metadata:
      annotations:
        checksum/configuration: 497ca8dd005acf277ac0dcd94939ca2fe3b407a27de324e0536356f3fd7e679f
      labels:
        app.kubernetes.io/name: mysql
        helm.sh/chart: mysql-8.6.2
        app.kubernetes.io/instance: db01
        app.kubernetes.io/managed-by: Helm
        app.kubernetes.io/component: primary
    spec:
      serviceAccountName: db01-mysql
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - podAffinityTerm:
              labelSelector:
                matchLabels:
                  app.kubernetes.io/name: mysql
                  app.kubernetes.io/instance: db01
                  app.kubernetes.io/component: primary
              topologyKey: kubernetes.io/hostname
            weight: 1
      securityContext:
        fsGroup: 1001
      containers:
      - name: mysql
        image: docker.io/bitnami/mysql:8.0.25-debian-10-r16
        imagePullPolicy: "IfNotPresent"
        securityContext:
          runAsUser: 1001
        env:
        - name: BITNAMI_DEBUG
          value: "false"
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: db01-mysql
              key: mysql-root-password
        - name: MYSQL_USER
          value: "admin"
        - name: MYSQL_PASSWORD
          valueFrom:
            secretKeyRef:
              name: db01-mysql
              key: mysql-password
        - name: MYSQL_DATABASE
          value: "my_database"
        ports:
        - name: mysql
          containerPort: 3306
        livenessProbe:
          failureThreshold: 3
          initialDelaySeconds: 120
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
          exec:
            command:
            - /bin/bash
            - -ec
            - |
              password_aux="${MYSQL_ROOT_PASSWORD:-}"
              if [[ -f "${MYSQL_ROOT_PASSWORD_FILE:-}" ]]; then
                  password_aux=$(cat "$MYSQL_ROOT_PASSWORD_FILE")
              fi
              mysqladmin status -uroot -p"${password_aux}"
        readinessProbe:
          failureThreshold: 3
          initialDelaySeconds: 30
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
          exec:
            command:
            - /bin/bash
            - -ec
            - |
              password_aux="${MYSQL_ROOT_PASSWORD:-}"
              if [[ -f "${MYSQL_ROOT_PASSWORD_FILE:-}" ]]; then
                  password_aux=$(cat "$MYSQL_ROOT_PASSWORD_FILE")
              fi
              mysqladmin status -uroot -p"${password_aux}"
        startupProbe:
          failureThreshold: 60
          initialDelaySeconds: 120
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
          exec:
            command:
            - /bin/bash
            - -ec
            - |
              password_aux="${MYSQL_ROOT_PASSWORD:-}"
              if [[ -f "${MYSQL_ROOT_PASSWORD_FILE:-}" ]]; then
                  password_aux=$(cat "$MYSQL_ROOT_PASSWORD_FILE")
              fi
              mysqladmin status -uroot -p"${password_aux}"
        resources:
          limits: {}
          requests: {}
        volumeMounts:
        - name: data
          mountPath: /bitnami/mysql
        - name: config
          mountPath: /opt/bitnami/mysql/conf/my.cnf
          subPath: my.cnf
      volumes:
      - name: config
        configMap:
          name: db01-mysql
  volumeClaimTemplates:
  - metadata:
      name: data
      labels:
        app.kubernetes.io/name: mysql
        app.kubernetes.io/instance: db01
        app.kubernetes.io/component: primary
    spec:
      accessModes:
      - "ReadWriteOnce"
      resources:
        requests:
          storage: "8Gi"
