apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    component: horizontal-elasticity-strategy-controller
    tier: control-plane
  name: horizontal-elasticity-strategy-controller
  namespace: polaris
spec:
  selector:
    matchLabels:
      component: horizontal-elasticity-strategy-controller
      tier: control-plane
  replicas: 1
  template:
    metadata:
      labels:
        component: horizontal-elasticity-strategy-controller
        tier: control-plane
    spec:
      serviceAccountName: horizontal-elasticity-strategy-controller
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                  # Ensure that the controller is only scheduled on Intel 64-bit nodes.
                  - key: kubernetes.io/arch
                    operator: In
                    values:
                      - amd64
      tolerations:
        # Ensure that the controller can be scheduled on master nodes.
        - key: node-role.kubernetes.io/master
          operator: Exists
          effect: NoSchedule
      containers:
      - image: polarissloc/horizontal-elasticity-strategy:latest
        name: elasticity-controller
        resources:
          limits:
            cpu: 1000m
            memory: 1Gi
        securityContext:
          privileged: false
        env:
          # Workaround for an issue with kubernetes-client when using IPv6 (https://github.com/kubernetes-client/javascript/issues/599)
          - name: KUBERNETES_SERVICE_HOST
            value: kubernetes.default.svc
          # Set up a 10 minute connection check interval for the ObjectKind watches.
          # This is a temporary workaround for occasional watch disconnect issues that
          # are not reported by the Kubernetes client library.
          # See https://github.com/kubernetes-client/javascript/issues/596#issuecomment-792067322
          # You can disable this check by removing this env var.
          - name: POLARIS_CONNECTION_CHECK_TIMEOUT_MS
            value: "600000"

