# _helpers.tpl
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "percona-xtradb-cluster.name" -}}
{{- default "pxc" .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "percona-xtradb-cluster.fullname" -}}
{{- $name := default "pxc" .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a short cluster name in order to fulfill Percona's `wsrep_cluster_name` variable max size.
https://www.percona.com/doc/percona-xtradb-cluster/LATEST/wsrep-system-index.html#wsrep_cluster_name
*/}}
{{- define "percona-xtradb-cluster.shortname" -}}
{{- $name := default "pxc" .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 32 | trimSuffix "-" -}}
{{- end -}}

{{- define "percona-xtradb-cluster.statefulset.apiVersion" -}}
{{- if .Capabilities.APIVersions.Has "apps/v1/StatefulSet" -}}
{{- print "apps/v1" -}}
{{- else -}}
{{- print "apps/v1beta2" -}}
{{- end -}}
{{- end -}}
 # config-map_mysql-config.yaml
kind: ConfigMap
apiVersion: v1
metadata:
  name: {{ template "percona-xtradb-cluster.fullname" . }}-config-files
  labels:
    app: {{ template "percona-xtradb-cluster.fullname" . }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
data:
{{- if .Values.configFiles }}
{{ toYaml .Values.configFiles | indent 2 }}
{{ if not (index .Values.configFiles "node.cnf") }}
  node.cnf: |
{{ .Files.Get "files/node.cnf" | indent 4 }}
{{ end }}
{{ else }}
  node.cnf: |
{{ .Files.Get "files/node.cnf" | indent 4 }}
{{ end }}
 # config-map_startup-scripts.yaml
kind: ConfigMap
apiVersion: v1
metadata:
  name: {{ template "percona-xtradb-cluster.fullname" . }}-startup-scripts
  labels:
    app: {{ template "percona-xtradb-cluster.fullname" . }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
data:
  entrypoint.sh: |
{{ .Files.Get "files/entrypoint.sh" | indent 4 }}
  functions.sh: |
{{ .Files.Get "files/functions.sh" | indent 4 }}
 # pdb.yaml
{{- if .Values.podDisruptionBudget.enabled }}
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
  labels:
    app: {{ template "percona-xtradb-cluster.fullname" . }}
    chart: {{ .Chart.Name }}-{{ .Chart.Version }}
    heritage: {{ .Release.Service }}
    release: {{ .Release.Name }}
  name: {{ template "percona-xtradb-cluster.fullname" . }}-pdb
spec:
{{- if .Values.podDisruptionBudget.minAvailable }}
  minAvailable: {{ .Values.podDisruptionBudget.minAvailable }}
{{- end }}
{{- if .Values.podDisruptionBudget.maxUnavailable }}
  maxUnavailable: {{ .Values.podDisruptionBudget.maxUnavailable }}
{{- end }}
  selector:
    matchLabels:
      app: {{ template "percona-xtradb-cluster.fullname" . }}
      release: {{ .Release.Name }}
{{- end }}
 # prometheusrule.yaml
{{ if and .Values.metricsExporter.enabled .Values.prometheus.operator.enabled .Values.prometheus.operator.prometheusRule.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  name: {{ template "percona-xtradb-cluster.fullname" . }}
{{- if .Values.prometheus.operator.prometheusRule.namespace }}
  namespace: {{ .Values.prometheus.operator.prometheusRule.namespace }}
{{- end }}
  labels:
    app: {{ template "percona-xtradb-cluster.fullname" . }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    heritage: "{{ .Release.Service }}"
    release: "{{ .Release.Name }}"
{{- if .Values.prometheus.operator.prometheusRule.selector }}
{{ toYaml .Values.prometheus.operator.prometheusRule.selector | indent 4 }}
{{- end }}
spec:
  groups:
  - name: {{ template "percona-xtradb-cluster.fullname" . }}-alerts
    rules:
    - alert: MySQLGaleraNotReady
      annotations:
        message: Galera cluster node not ready
      expr: mysql_global_status_wsrep_ready{service="{{ template "percona-xtradb-cluster.fullname" . }}-metrics"} != 1
      for: 5m
      labels:
        severity: critical
{{- if .Values.prometheus.operator.prometheusRule.labels }}
{{ toYaml .Values.prometheus.operator.prometheusRule.labels | indent 8 }}
{{- end }}
    - alert: MySQLGaleraOutOfSync
      annotations:
        message: Galera cluster node out of sync
      expr: (mysql_global_status_wsrep_local_state{service="{{ template "percona-xtradb-cluster.fullname" . }}-metrics"} != 4 and mysql_global_variables_wsrep_desync{service="{{ template "percona-xtradb-cluster.fullname" . }}-metrics"} == 0)
      for: 5m
      labels:
        severity: critical
{{- if .Values.prometheus.operator.prometheusRule.labels }}
{{ toYaml .Values.prometheus.operator.prometheusRule.labels | indent 8 }}
{{- end }}
    - alert: MySQLGaleraDonorFallingBehind
      annotations:
        message: xtradb cluster donor node falling behind
      expr: (mysql_global_status_wsrep_local_state{service="{{ template "percona-xtradb-cluster.fullname" . }}-metrics"} == 2 and mysql_global_status_wsrep_local_recv_queue{service="{{ template "percona-xtradb-cluster.fullname" . }}-metrics"} > 100)
      for: 5m
      labels:
        severity: warning
{{- if .Values.prometheus.operator.prometheusRule.labels }}
{{ toYaml .Values.prometheus.operator.prometheusRule.labels | indent 8 }}
{{- end }}
    - alert: MySQLInnoDBLogWaits
      annotations:
        message: MySQL innodb log writes stalling
      expr: rate(mysql_global_status_innodb_log_waits{service="{{ template "percona-xtradb-cluster.fullname" . }}-metrics"}[15m]) > 10
      for: 5m
      labels:
        severity: warning
{{- if .Values.prometheus.operator.prometheusRule.labels }}
{{ toYaml .Values.prometheus.operator.prometheusRule.labels | indent 8 }}
{{- end }}
{{ end }}
 # pxc-test-cm.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ template "percona-xtradb-cluster.fullname" . }}-tests
data:
  run.sh: |-
    echo "Testing Percona XtraDB Cluster"
    creds="-uroot -p${MYSQL_ROOT_PASSWORD} -h {{ template "percona-xtradb-cluster.fullname" . }}"
    echo "==> basic mysql ping"
    mysqladmin $creds ping
    [[ $? != "0" ]] && exit $?
    echo "==> test basic query"
    mysql $creds -e "select now() \G"
    [[ $? != "0" ]] && exit $?
    echo "==> checking if cluster is ready"
    mysql $creds -e "SHOW GLOBAL STATUS LIKE 'wsrep_ready' \G" | grep Value | awk '{ print $2}' | grep ON
    [[ $? != "0" ]] && exit $?
    echo "==> checking if cluster size matches replica count"
    cluster_size=$(mysql $creds -e "SHOW GLOBAL STATUS LIKE 'wsrep_cluster_size' \G" | grep Value | awk '{ print $2}')
    [[ $? != "0" ]] && exit $?
    [[ "${cluster_size}" == "{{ .Values.replicas }}" ]] || exit 1
    echo "SUCCESS"
    exit 0
 # pxc-test.yaml
apiVersion: v1
kind: Pod
metadata:
  name: "{{ .Release.Name }}-test"
  annotations:
    "helm.sh/hook": test-success
spec:
  containers:
  - name: pxc-test
    image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
    imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
    command: ["bash", "/tests/run.sh"]
    env:
    - name: MYSQL_ROOT_PASSWORD
      valueFrom:
        secretKeyRef:
          name: {{ template "percona-xtradb-cluster.fullname" . }}
          key: mysql-root-password
    volumeMounts:
    - mountPath: /tests
      name: tests
  volumes:
  - name: tests
    configMap:
      name: {{ template "percona-xtradb-cluster.fullname" . }}-tests
  restartPolicy: Never
 # secrets.yaml
apiVersion: v1
kind: Secret
metadata:
  name: {{ template "percona-xtradb-cluster.fullname" . }}
  labels:
    app: {{ template "percona-xtradb-cluster.fullname" . }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
type: Opaque
data:
  {{ if .Values.mysqlRootPassword }}
  mysql-root-password:  {{ .Values.mysqlRootPassword | b64enc | quote }}
  {{ else }}
  mysql-root-password: {{ randAlphaNum 10 | b64enc | quote }}
  {{ end }}
  {{ if .Values.mysqlPassword }}
  mysql-password:  {{ .Values.mysqlPassword | b64enc | quote }}
  {{ else }}
  mysql-password: {{ randAlphaNum 10 | b64enc | quote }}
  {{ end }}
  {{ if .Values.xtraBackupPassword }}
  xtrabackup-password:  {{ .Values.xtraBackupPassword | b64enc | quote }}
  {{ else }}
  xtrabackup-password: {{ randAlphaNum 10 | b64enc | quote }}
  {{ end }}
{{- if .Values.ssl.enabled }}
{{ if .Values.ssl.certificates }}
{{- range .Values.ssl.certificates }}
---
apiVersion: v1
kind: Secret
metadata:
  name: {{ .name }}
  labels:
    app: {{ template "percona-xtradb-cluster.fullname" $ }}
    chart: "{{ $.Chart.Name }}-{{ $.Chart.Version }}"
    release: "{{ $.Release.Name }}"
    heritage: "{{ $.Release.Service }}"
type: Opaque
data:
  ca.pem: {{ .ca | b64enc }}
  server-cert.pem: {{ .cert | b64enc }}
  server-key.pem: {{ .key | b64enc }}
{{- end }}
{{- end }}
{{- end }}
 # service-metrics.yaml
{{ if .Values.metricsExporter.enabled }}
---
apiVersion: v1
kind: Service
metadata:
  name: "{{ template "percona-xtradb-cluster.fullname" . }}-metrics"
  labels:
    app: {{ template "percona-xtradb-cluster.fullname" . }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
spec:
  clusterIP: None
  ports:
  - name: metrics
    port: 9104
  selector:
    app: {{ template "percona-xtradb-cluster.fullname" . }}
    release: "{{ .Release.Name }}"
{{ end }}
 # service-percona.yaml
apiVersion: v1
kind: Service
metadata:
  name: {{ template "percona-xtradb-cluster.fullname" . }}
  labels:
    app: {{ template "percona-xtradb-cluster.fullname" . }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
spec:
  {{- if .Values.service.percona.headless }}
  clusterIP: None
  {{- end }}
  ports:
  - name: mysql
    port: 3306
    targetPort: mysql
  selector:
    app: {{ template "percona-xtradb-cluster.fullname" . }}
    release: "{{ .Release.Name }}"
 # service-repl.yaml
apiVersion: v1
kind: Service
metadata:
  name: "{{ template "percona-xtradb-cluster.fullname" . }}-repl"
  labels:
    app: {{ template "percona-xtradb-cluster.fullname" . }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
spec:
  clusterIP: None
  ports:
  - name: galera
    port: 4567
  - name: state-xfer
    port: 4568
  - name: state-snap
    port: 4444
  selector:
    app: {{ template "percona-xtradb-cluster.fullname" . }}
    release: "{{ .Release.Name }}"
 # servicemonitor.yaml
{{ if and .Values.metricsExporter.enabled .Values.prometheus.operator.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: {{ template "percona-xtradb-cluster.fullname" . }}
{{- if .Values.prometheus.operator.serviceMonitor.namespace }}
  namespace: {{ .Values.prometheus.operator.serviceMonitor.namespace }}
{{- end }}
  labels:
    app: {{ template "percona-xtradb-cluster.fullname" . }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    heritage: "{{ .Release.Service }}"
    release: "{{ .Release.Name }}"
{{- if .Values.prometheus.operator.serviceMonitor.selector }}
{{ toYaml .Values.prometheus.operator.serviceMonitor.selector | indent 4 }}
{{- end }}
spec:
  selector:
    matchLabels:
      app: {{ template "percona-xtradb-cluster.fullname" . }}
      release: {{ .Release.Name }}
  endpoints:
  - port: metrics
    interval: {{ .Values.prometheus.operator.serviceMonitor.interval }}
  namespaceSelector:
    any: true
{{ end }}
 # statefulset.yaml
apiVersion: {{ template "percona-xtradb-cluster.statefulset.apiVersion" . }}
kind: StatefulSet
metadata:
  name: {{ template "percona-xtradb-cluster.fullname" . }}
  labels:
    app: {{ template "percona-xtradb-cluster.fullname" . }}
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
spec:
  replicas: {{ .Values.replicas }}
  selector:
    matchLabels:
      app: {{ template "percona-xtradb-cluster.fullname" . }}
      release: "{{ .Release.Name }}"
  serviceName: {{ template "percona-xtradb-cluster.fullname" . }}
  template:
    metadata:
      labels:
        app: {{ template "percona-xtradb-cluster.fullname" . }}
        chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
        release: "{{ .Release.Name }}"
        heritage: "{{ .Release.Service }}"
    {{- if .Values.podAnnotations }}
      annotations:
{{ toYaml .Values.podAnnotations | indent 8 }}
    {{- end }}
    spec:
      {{- with .Values.serviceAccountName }}
      serviceAccountName: "{{ . }}"
      {{- end }}
      {{- with .Values.securityContext }}
      securityContext:
        {{ . | toYaml | nindent 8 }}
      {{- end }}
      initContainers:
      - name: "remove-lost-found"
        image: "busybox:1.25.0"
        resources:
{{ toYaml .Values.initResources | indent 10 }}
        imagePullPolicy: IfNotPresent
        command:
        - "rm"
        - "-fr"
        - "/var/lib/mysql/lost+found"
        volumeMounts:
        - name: mysql-data
          mountPath: /var/lib/mysql
      containers:
      - name: database
        image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
        imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
        command:
        - "/bin/bash"
        - "/startup-scripts/entrypoint.sh"
        resources:
{{ toYaml .Values.resources | indent 10 }}
        env:
        {{- if .Values.mysqlAllowEmptyPassword }}
        - name: MYSQL_ALLOW_EMPTY_PASSWORD
          value: "true"
        {{- else }}
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: {{ template "percona-xtradb-cluster.fullname" . }}
              key: mysql-root-password
        - name: MYSQL_PASSWORD
          valueFrom:
            secretKeyRef:
              name: {{ template "percona-xtradb-cluster.fullname" . }}
              key: mysql-password
        {{- end }}
        - name: XTRABACKUP_PASSWORD
          valueFrom:
            secretKeyRef:
              name: {{ template "percona-xtradb-cluster.fullname" . }}
              key: xtrabackup-password
        - name: MYSQL_USER
          value: {{ default "" .Values.mysqlUser | quote }}
        - name: MYSQL_DATABASE
          value: {{ default "" .Values.mysqlDatabase | quote }}
        - name: ALLOW_ROOT_FROM
          value: {{ .Values.allowRootFrom | quote }}
        - name: CLUSTER_NAME
          value: {{ template "percona-xtradb-cluster.fullname" . }}
        - name: SHORT_CLUSTER_NAME
          value: {{ template "percona-xtradb-cluster.shortname" . }}
        - name: K8S_SERVICE_NAME
          value: {{ template "percona-xtradb-cluster.fullname" . }}-repl
        - name: PXC_STRICT_MODE
          value: {{ default "ENFORCING" .Values.pxc_strict_mode | quote }}
        - name: DEBUG
          value: "true"
        ports:
        - name: mysql
          containerPort: 3306
        - name: galera-repl
          containerPort: 4567
        - name: state-transfer
          containerPort: 4568
        - name: state-snapshot
          containerPort: 4444
        livenessProbe:
          exec:
            command:
              - "/bin/bash"
              - "-c"
              - "mysqladmin ping || test -e /var/lib/mysql/sst_in_progress"
          initialDelaySeconds: 30
          timeoutSeconds: 2
        readinessProbe:
          exec:
            command: ["mysql", "--defaults-extra-file=/root/.my.cnf", "-h", "127.0.0.1", "-e", "SELECT 1"]
          initialDelaySeconds: 30
          timeoutSeconds: 2
        volumeMounts:
        - name: mysql-data
          mountPath: /var/lib/mysql
        - name: mysql-startup-scripts
          mountPath: /startup-scripts
        - name: mysql-config-files
          mountPath: /etc/mysql/conf.d
        - name: slash-root
          mountPath: /root
        - name: var-log
          mountPath: /var/log
        {{- if .Values.ssl.enabled }}
        - name: certificates
          mountPath: /ssl
        {{- end }}
      {{ if .Values.logTail }}
      - name: "logs"
        image: "busybox:1.25.0"
        resources:
{{ toYaml .Values.initResources | indent 10 }}
        imagePullPolicy: IfNotPresent
        command:
        - "tail"
        - "-f"
        - "/var/log/mysqld.log"
        volumeMounts:
        - name: var-log
          mountPath: /var/log
      {{ end }}
      {{ if .Values.metricsExporter.enabled }}
      - name: metrics
        {{- if .Values.metricsExporter.tag }}
        image: prom/mysqld-exporter:{{ .Values.metricsExporter.tag }}
        {{- else }}
        image: prom/mysqld-exporter
        {{- end }}
        imagePullPolicy: IfNotPresent
{{- if .Values.metricsExporter.commandOverrides }}
        command:
{{ toYaml .Values.metricsExporter.commandOverrides | indent 8 }}
{{- end }}
{{- if .Values.metricsExporter.argsOverrides }}
        args:
{{ toYaml .Values.metricsExporter.argsOverrides | indent 8 }}
{{- end }}
        ports:
        - name: metrics
          containerPort: 9104
        volumeMounts:
        - name: slash-root
          mountPath: /root
        livenessProbe:
          exec:
            command: ["wget","-q","-O","-","localhost:9104"]
          initialDelaySeconds: 30
          timeoutSeconds: 2
        readinessProbe:
          exec:
            command: ["wget","-q","-O","-","localhost:9104"]
          initialDelaySeconds: 30
          timeoutSeconds: 2
      {{ end }}
      volumes:
      - name: slash-root
        emptyDir: {}
      - name: var-log
        emptyDir: {}
      - name: mysql-config-files
        configMap:
          name: {{ template "percona-xtradb-cluster.fullname" . }}-config-files
      - name: mysql-startup-scripts
        configMap:
          name: {{ template "percona-xtradb-cluster.fullname" . }}-startup-scripts
      {{- if not .Values.persistence.enabled }}
      - name: mysql-data
        emptyDir: {}
      {{- end -}}
      {{- if .Values.ssl.enabled }}
      - name: certificates
        secret:
          secretName: {{ .Values.ssl.secret }}
      {{- end }}
      {{- if .Values.tolerations }}
      tolerations:
{{ toYaml .Values.tolerations | indent 8 }}
      {{- end -}}
      {{- if .Values.nodeSelector }}
      nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
      {{- end -}}
  {{- if .Values.persistence.enabled }}
  volumeClaimTemplates:
  - metadata:
      name: mysql-data
    spec:
      accessModes: [{{ .Values.persistence.accessMode | quote }}]
      {{- if .Values.persistence.storageClass }}
      {{- if (eq "-" .Values.persistence.storageClass) }}
      storageClassName: ""
      {{- else }}
      storageClassName: "{{ .Values.persistence.storageClass }}"
      {{- end }}
      {{- end }}
      resources:
        requests:
          storage: {{ .Values.persistence.size | quote }}
  {{- end -}}

# Default values for Percona XtraDB Cluster

## percona image and version
## ref: https://hub.docker.com/r/percona/percona-xtradb-cluster/tags/
image:
  repository: "percona/percona-xtradb-cluster"
  tag: "5.7.19"
  pullPolicy: IfNotPresent

# Desired number of members of xtradb cluster
replicas: 3

## Specify password for root user
##
# mysqlRootPassword: not-a-secure-password

## Specify password for xtradb backup user
##
# xtraBackupPassword: replicate-my-data

## Uncomment to create a database user
##
# mysqlUser: test
# mysqlPassword: test

## Allow unauthenticated access, uncomment to enable
##
# mysqlAllowEmptyPassword: true

## Uncomment to Create a database
##
# mysqlDatabase: test

## Configure pxc_strict_mode
## ref: https://www.percona.com/doc/percona-xtradb-cluster/LATEST/features/pxc-strict-mode.html
## pxc_strict_mode: ENFORCING

## hosts to allow root user access from
# set to "127.0.0.1" to deny remote root.
allowRootFrom: "%"

## Persist data to a persistent volume
persistence:
  enabled: false
  ## percona data Persistent Volume Storage Class
  ## If defined, storageClassName: <storageClass>
  ## If set to "-", storageClassName: "", which disables dynamic provisioning
  ## If undefined (the default) or set to null, no storageClassName spec is
  ##   set, choosing the default provisioner.  (gp2 on AWS, standard on
  ##   GKE, AWS & OpenStack)
  ##
  # storageClass: "-"
  accessMode: ReadWriteOnce
  size: 8Gi

## Node labels for pod assignment
## Ref: https://kubernetes.io/docs/user-guide/node-selection/
##
nodeSelector: {}

## Pod annotations
## Ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/
##
podAnnotations: {}

## Tolerations labels for pod assignment
## Allow the scheduling on tainted nodes (requires Kubernetes >= 1.6)
## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
##
tolerations: []

## Configure resource requests and limits
## ref: http://kubernetes.io/docs/user-guide/compute-resources/
##
# resources:
#  requests:
#    memory: 256Mi
#    cpu: 100m

# initResources:
#  requests:
#    memory: 128Mi
#    cpu: 100m

configFiles:
  node.cnf: |+
    [mysqld]
    datadir=/var/lib/mysql
    default_storage_engine=InnoDB
    binlog_format=ROW
    innodb_flush_log_at_trx_commit  = 0
    innodb_flush_method             = O_DIRECT
    innodb_file_per_table           = 1
    innodb_autoinc_lock_mode=2
    bind_address = 0.0.0.0
    wsrep_slave_threads=2
    wsrep_cluster_address=gcomm://
    wsrep_provider=/usr/lib/galera3/libgalera_smm.so
    wsrep_cluster_name=galera
    wsrep_sst_method=xtrabackup-v2

## When set to true will create sidecar for `prom/mysqld-exporter`
## metrics exporting
metricsExporter:
  enabled: false
  commandOverrides: []
  argsOverrides: []

prometheus:
  ## Are you using [Prometheus Operator](https://coreos.com/operators/prometheus/docs/latest/user-guides/getting-started.html)?
  operator:
    ## Setting to true will create Prometheus-Operator specific resources like ServiceMonitors
    enabled: false

    ## Configures alerts for Prometheus to pick up
    prometheusRule:
      enabled: true

      ## Labels to add to alerts
      labels: {}

      ## Namespace which Prometheus is installed in
      # namespace: monitoring

      ## Label Selector for Prometheus to find alert rules
      # selector:
      #   prometheus: kube-prometheus

    ## Configures targets for Prometheus to pick up
    serviceMonitor:
      ## Interval at which Prometheus will scrape metrics exporter
      interval: 10s

      ## Namespace which Prometheus is installed in
      # namespace: monitoring

      ## Label Selector for Prometheus to find ServiceMonitors
      # selector:
      #   prometheus: kube-prometheus

## When set to true will create sidecar to tail mysql log
logTail: true

ssl:
  enabled: false
  secret: mysql-ssl-certs
  certificates:
#  - name: mysql-ssl-certs
#    ca: |-
#      -----BEGIN CERTIFICATE-----
#      ...
#      -----END CERTIFICATE-----
#    cert: |-
#      -----BEGIN CERTIFICATE-----
#      ...
#      -----END CERTIFICATE-----
#    key: |-
#      -----BEGIN RSA PRIVATE KEY-----
#      ...
#      -----END RSA PRIVATE KEY-----

## Configure PodDisruptionBudget
## ref: https://kubernetes.io/docs/concepts/workloads/pods/disruptions/
#
podDisruptionBudget:
  enabled: false
  # minAvailable: 1
  maxUnavailable: 1

## Set the percona kubernetes service headless (no load-balancing)
## ref: https://kubernetes.io/docs/concepts/services-networking/service/#headless-services
service:
  percona:
    headless: false

## Set the serviceAccountName.
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/
# serviceAccountName:

## Set the securityContext parameters.
## 999 is the UID of mysql user.
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
# securityContext:
#   runAsUser: 999
#   runAsGroup: 999
#   fsGroup: 999
