---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: hetzner-cloud-controller-manager
  namespace: kube-system
spec:
  replicas: 1
  selector:
    matchLabels:
      app: hetzner-cloud-controller-manager
  template:
    metadata:
      labels:
        app: hetzner-cloud-controller-manager
      annotations:
        scheduler.alpha.kubernetes.io/critical-pod: ''
    spec:
      serviceAccountName: hetzner-cloud-controller-manager
      dnsPolicy: Default
      tolerations:
        # this taint is set by all kubelets running `--cloud-provider=external`
        # so we should tolerate it to schedule the cloud controller manager
        - key: "node.cloudprovider.kubernetes.io/uninitialized"
          value: "true"
          effect: "NoSchedule"
        - key: "CriticalAddonsOnly"
          operator: "Exists"
        # cloud controller manages should be able to run on masters
        - key: "node-role.kubernetes.io/master"
          effect: NoSchedule
        - key: "node.kubernetes.io/not-ready"
          effect: "NoSchedule"
      containers:
        - image: docker.io/sh4d1/hetzner-cloud-controller-manager
          imagePullPolicy: Always
          name: hetzner-cloud-controller-manager
          command:
            - "/bin/hcloud-cloud-controller-manager"
            - "--cloud-provider=hetzner"
            - "--leader-elect=true"
            - "--allow-untagged-cloud"
          resources:
            requests:
              cpu: 100m
              memory: 50Mi
            limits:
              cpu: 200m
              memory: 100Mi
          securityContext:
            runAsUser: 40801
            runAsGroup: 40801
          env:
            - name: NODE_NAME
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
            - name: HCLOUD_TOKEN
              valueFrom:
                secretKeyRef:
                  name: hetzner-cloud-controller-manager
                  key: token
            - name: HROBOT_USER
              valueFrom:
                secretKeyRef:
                  name: hetzner-cloud-controller-manager
                  key: robot_user
            - name: HROBOT_PASS
              valueFrom:
                secretKeyRef:
                  name: hetzner-cloud-controller-manager
                  key: robot_password
            - name: HCLOUD_LOAD_BALANCERS_ENABLED
              value: "false"
