apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: kucero # Must match "--ds-name"
  namespace: kube-system # Must match "--ds-namespace"
spec:
  selector:
    matchLabels:
      name: kucero
  revisionHistoryLimit: 3
  updateStrategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        name: kucero
    spec:
      serviceAccountName: kucero
      tolerations:
        - key: node-role.kubernetes.io/master
          operator: Exists
          effect: NoSchedule
      hostPID: true # Facilitate entering the host mount namespace via init
      restartPolicy: Always
      volumes:
        - name: kubelet-conf
          hostPath:
            path: /etc/kubernetes/kubelet.conf
            type: File
        - name: ca-crt
          hostPath:
            path: /etc/kubernetes/pki/ca.crt
            type: File
        - name: ca-key
          hostPath:
            path: /etc/kubernetes/pki/ca.key
            type: FileOrCreate
        - name: kubelet-config-yaml
          hostPath:
            path: /var/lib/kubelet/config.yaml
            type: File
      containers:
        - name: kucero
          image: quay.io/jenting/kucero:v1.5.1
          imagePullPolicy: IfNotPresent
          securityContext:
            privileged: true # Give permission to nsenter /proc/1/ns/mnt
          env:
            # Pass in the name of the node on which this pod is scheduled
            # for use with drain/uncordon operations and lock acquisition
            - name: KUCERO_NODE_NAME
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
          command:
            - /usr/bin/kucero
          volumeMounts:
            - mountPath: /etc/kubernetes/kubelet.conf
              name: kubelet-conf
            - mountPath: /etc/kubernetes/pki/ca.crt
              name: ca-crt
              readOnly: true
            - mountPath: /etc/kubernetes/pki/ca.key
              name: ca-key
              readOnly: true
            - mountPath: /var/lib/kubelet/config.yaml
              name: kubelet-config-yaml
