apiVersion: apps/v1
kind: Deployment
metadata:
  name: dispatcher
  namespace: system
  labels:
    control-plane: dispatcher
spec:
  selector:
    matchLabels:
      control-plane: dispatcher
  replicas: 1
  template:
    metadata:
      labels:
        control-plane: dispatcher
    spec:
      securityContext:
        runAsNonRoot: true
      containers:
      - command:
        - /dispatcher
        args:
        - --enable-leader-election
        - --kube-cluster-config-map-name=region-to-kube-clusters
        - --kube-cluster-config-map-namespace=$(NAMESPACE)
        - --infra-kubeconfig=/infra/kubeconfig
        image: dispatcher:latest
        imagePullPolicy: IfNotPresent
        name: dispatcher
        env:
        - name: NAMESPACE
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: metadata.namespace
        volumeMounts:
        - name: infra-kubeconfig
          mountPath: /infra
        securityContext:
          allowPrivilegeEscalation: false
        livenessProbe:
          httpGet:
            path: /healthz
            port: 8081
          initialDelaySeconds: 15
          periodSeconds: 20
        readinessProbe:
          httpGet:
            path: /readyz
            port: 8081
          initialDelaySeconds: 5
          periodSeconds: 10
        resources:
          limits:
            cpu: 100m
            memory: 256Mi
          requests:
            cpu: 100m
            memory: 256Mi
      volumes:
      - name: infra-kubeconfig
        secret:
          # See src/dispatcher.ts#infraAPIKubeconfigSecretName
          secretName: infra-api-kubeconfig
      serviceAccountName: dispatcher
      terminationGracePeriodSeconds: 10
