apiVersion: apps/v1
kind: Deployment
metadata:
  name: kube-valet
  namespace: kube-valet
  labels:
    k8s-app: kube-valet
spec:
  progressDeadlineSeconds: 600
  # Two replicas should be enough to provide for high-availabilty
  # More replicas may be needed under increased pod creation load
  replicas: 2
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      k8s-app: kube-valet
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
    type: RollingUpdate
  template:
    metadata:
      labels:
        k8s-app: kube-valet
    spec:
      # For enhanced stability, kube-valet pods will try to avoid running on the same node.
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 100
            podAffinityTerm:
              labelSelector:
                matchExpressions:
                - key: k8s-app
                  operator: In
                  values:
                  - kube-valet
              topologyKey: kubernetes.io/hostname
      containers:
      - name: kube-valet
        # Production systems should use a stable version tag
        image: domoinc/kube-valet:latest
        command:
          - /kube-valet
          - --in-cluster # Use in-cluster config to reach Kuberntes api
          - --leader-elect # Run with leader election on so only one pod is active at a time.
          - --leader-elect-namespace=kube-valet # Leader-elect in own namespace
          - --cert=/tls/server.pem
          - --key=/tls/server-key.pem
        readinessProbe:
          httpGet:
            port: 443
            path: /healthz
            scheme: HTTPS
          initialDelaySeconds: 5
          timeoutSeconds: 5
        livenessProbe:
          httpGet:
            port: 443
            path: /healthz
            scheme: HTTPS
          initialDelaySeconds: 5
          timeoutSeconds: 10
        volumeMounts:
          - name: tls
            mountPath: /tls
        imagePullPolicy: Always
      volumes:
        - name: tls
          secret:
            secretName: kube-valet
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      serviceAccount: kube-valet
      serviceAccountName: kube-valet
      terminationGracePeriodSeconds: 300
