---
# Source: matomo/charts/mysql/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: RELEASE-NAME-mysql
  labels:
    app.kubernetes.io/name: mysql
    app.kubernetes.io/instance: RELEASE-NAME
    app.kubernetes.io/managed-by: Helm
    helm.sh/chart: mysql-0.1.0
spec:
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app.kubernetes.io/name: mysql
      app.kubernetes.io/instance: RELEASE-NAME
  template:
    metadata:
      labels:
        app.kubernetes.io/name: mysql
        app.kubernetes.io/instance: RELEASE-NAME
    spec:
      serviceAccountName: default
      initContainers:
      - name: "remove-lost-found"
        image: "busybox:1.32"
        imagePullPolicy: "IfNotPresent"
        resources:
          requests:
            cpu: 10m
            memory: 10Mi
        command:  ["rm", "-fr", "/var/lib/mysql/lost+found"]
        volumeMounts:
        - name: data
          mountPath: /var/lib/mysql
      containers:
      - name: RELEASE-NAME-mysql
        image: "mysql:8.0.22"
        imagePullPolicy: "IfNotPresent"
        resources:
          requests:
            cpu: 100m
            memory: 256Mi
        env:
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: RELEASE-NAME-mysql
              key: mysql-root-password
        - name: MYSQL_PASSWORD
          valueFrom:
            secretKeyRef:
              name: RELEASE-NAME-mysql
              key: mysql-password
        - name: MYSQL_USER
          value: "matomo"
        - name: MYSQL_DATABASE
          value: "matomo"
        ports:
        - name: mysql
          containerPort: 3306
        livenessProbe:
          exec:
            command:
            - sh
            - -c
            - "mysqladmin ping -u root -p${MYSQL_ROOT_PASSWORD}"
          initialDelaySeconds: 30
          periodSeconds: 10
          timeoutSeconds: 5
          successThreshold: 1
          failureThreshold: 3
        readinessProbe:
          exec:
            command:
            - sh
            - -c
            - "mysqladmin ping -u root -p${MYSQL_ROOT_PASSWORD}"
          initialDelaySeconds: 5
          periodSeconds: 10
          timeoutSeconds: 1
          successThreshold: 1
          failureThreshold: 3
        volumeMounts:
        - name: data
          mountPath: /var/lib/mysql
      volumes:
      - name: data
        persistentVolumeClaim:
          claimName: RELEASE-NAME-mysql
