apiVersion: apps/v1
kind: Deployment
metadata:
  name: config-center
spec:
  replicas: 2
  selector:
    matchLabels:
      app: config-center
  template:
    metadata:
      labels:
        app: config-center
    spec:
      serviceAccountName: config-center-sa
      priorityClassName: system-cluster-critical
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 100
            podAffinityTerm:
              labelSelector:
                matchLabels:
                  app: config-center
              topologyKey: kubernetes.io/hostname
      containers:
      - name: config-center
        command:
        - /config-center
        args:
          - --config=/etc/config-center/config.toml
        image: tidbcloud/config-center:latest
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 8080
          protocol: TCP
        - containerPort: 8081
          protocol: TCP
        resources:
          requests:
            cpu: 250m
            memory: 512Mi
          limits:
            cpu: 1000m
            memory: 1024Mi
        readinessProbe:
          tcpSocket:
            port: 8081
          initialDelaySeconds: 3
          periodSeconds: 5
          failureThreshold: 3
        livenessProbe:
          tcpSocket:
            port: 8081
          initialDelaySeconds: 10
          periodSeconds: 10
          failureThreshold: 3
        volumeMounts:
        - mountPath: /etc/config-center
          name: config
          readOnly: true
        env:
          - name: DB_PASSWORD
            valueFrom:
              secretKeyRef:
                name: config-center-db-secret
                key: password
      volumes:
      - name: config
        configMap:
          name: config-center-config
