---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: daemon
  namespace: system
  labels:
    k8s-app: knode
spec:
  selector:
    matchLabels:
      name: knode
  minReadySeconds: 0
  updateStrategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 1
  template:
    metadata:
      annotations:
        knode.jpang.dev/mode: default
      labels:
        name: knode
    spec:
      hostPID: true # For entering the host mount namespace via init
      initContainers:
      - name: init
        image: knode:latest
        imagePullPolicy: Always
        command:
        - /knode
        args:
        - init
        resources:
          limits:
            memory: 500Mi
          requests:
            cpu: 10m
            memory: 50Mi
        securityContext:
          privileged: true # For nsenter /proc/1/ns/mnt
        volumeMounts:
        - name: configs
          mountPath: /configs
          readOnly: true
        - name: etc
          mountPath: /etc
        - name: tmp
          mountPath: /tmp
        - name: var-lib-kubelet
          mountPath: /var/lib/kubelet
      containers:
      - name: knode
        image: knode:latest
        imagePullPolicy: Always
        command:
        - /knode
        resources:
          limits:
            memory: 100Mi
          requests:
            cpu: 10m
            memory: 50Mi
        volumeMounts:
        - name: configs
          mountPath: /configs
          readOnly: true
        - name: etc
          mountPath: /etc
          readOnly: true
        - name: var-lib-kubelet
          mountPath: /var/lib/kubelet
          readOnly: true
      terminationGracePeriodSeconds: 30
      volumes:
      - name: configs
        configMap:
          name: config
      - name: etc
        hostPath:
          path: /etc
      - name: tmp
        hostPath:
          path: /tmp
      - name: var-lib-kubelet
        hostPath:
          path: /var/lib/kubelet
