apiVersion: pingcap.com/v1alpha1
kind: TidbCluster
metadata:
  name: {{ template "cluster.name" . }}
{{- if .Values.enableConfigMapRollout }}
  annotations:
    pingcap.com/pd.{{ template "cluster.name" . }}-pd.sha: {{ template "pd-configmap.data-digest" . }}
    pingcap.com/tikv.{{ template "cluster.name" . }}-tikv.sha: {{ template "tikv-configmap.data-digest" . }}
    pingcap.com/tidb.{{ template "cluster.name" . }}-tidb.sha: {{ template "tidb-configmap.data-digest" . }}
{{- end }}
  labels:
    app.kubernetes.io/name: {{ template "chart.name" . }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/component: tidb-cluster
    helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+"  "_" }}
    {{- if .Values.extraLabels }}
{{ toYaml .Values.extraLabels | indent 4 }}
    {{- end }}
spec:
  pvReclaimPolicy: {{ .Values.pvReclaimPolicy }}
  timezone: {{ .Values.timezone | default "UTC" }}
  services:
{{ toYaml .Values.services | indent 4 }}
  schedulerName: {{ .Values.schedulerName | default "default-scheduler" }}
  pd:
    replicas: {{ .Values.pd.replicas }}
    image: {{ .Values.pd.image }}
    imagePullPolicy: {{ .Values.pd.imagePullPolicy | default "IfNotPresent" }}
  {{- if .Values.pd.storageClassName }}
    storageClassName: {{ .Values.pd.storageClassName }}
  {{- end }}
  {{- if .Values.pd.resources }}
{{ toYaml .Values.pd.resources | indent 4 }}
  {{- end }}
    affinity:
{{ toYaml .Values.pd.affinity | indent 6 }}
    nodeSelector:
{{ toYaml .Values.pd.nodeSelector | indent 6 }}
  {{- if .Values.pd.tolerations }}
    tolerations:
{{ toYaml .Values.pd.tolerations | indent 4 }}
  {{- end }}
  {{- if .Values.pd.annotations }}
    annotations:
{{ toYaml .Values.pd.annotations | indent 6 }}
  {{- end }}
  tikv:
    privileged: true
    replicas: {{ .Values.tikv.replicas }}
    image: {{ .Values.tikv.image }}
    imagePullPolicy: {{ .Values.tikv.imagePullPolicy | default "IfNotPresent" }}
  {{- if .Values.tikv.storageClassName }}
    storageClassName: {{ .Values.tikv.storageClassName }}
  {{- end }}
  {{- if .Values.tikv.resources }}
{{ toYaml .Values.tikv.resources | indent 4 }}
  {{- end }}
    affinity:
{{ toYaml .Values.tikv.affinity | indent 6 }}
    nodeSelector:
{{ toYaml .Values.tikv.nodeSelector | indent 6 }}
  {{- if .Values.tikv.tolerations }}
    tolerations:
{{ toYaml .Values.tikv.tolerations | indent 4 }}
  {{- end }}
  {{- if .Values.tikv.annotations }}
    annotations:
{{ toYaml .Values.tikv.annotations | indent 6 }}
  {{- end }}
  tidb:
    replicas: {{ .Values.tidb.replicas }}
    image: {{ .Values.tidb.image }}
    imagePullPolicy: {{ .Values.tidb.imagePullPolicy | default "IfNotPresent" }}
  {{- if .Values.tidb.resources }}
{{ toYaml .Values.tidb.resources | indent 4 }}
  {{- end }}
    affinity:
{{ toYaml .Values.tidb.affinity | indent 6 }}
    nodeSelector:
{{ toYaml .Values.tidb.nodeSelector | indent 6 }}
  {{- if .Values.tidb.tolerations }}
    tolerations:
{{ toYaml .Values.tidb.tolerations | indent 4 }}
  {{- end }}
  {{- if .Values.tidb.annotations }}
    annotations:
{{ toYaml .Values.tidb.annotations | indent 6 }}
  {{- end }}
    binlogEnabled: {{ .Values.binlog.pump.create | default false }}
    maxFailoverCount: {{ .Values.tidb.maxFailoverCount | default 3 }}
    separateSlowLog: {{ .Values.tidb.separateSlowLog | default false }}
    slowLogTailer:
      image: {{ .Values.tidb.slowLogTailer.image }}
      imagePullPolicy: {{ .Values.tidb.slowLogTailer.imagePullPolicy | default "IfNotPresent" }}
      {{- if .Values.tidb.slowLogTailer.resources }}
{{ toYaml .Values.tidb.slowLogTailer.resources | indent 6 }}
      {{- end }}
