---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: sysbox-cleanup-k8s
  namespace: kube-system
spec:
  selector:
      matchLabels:
        sysbox-install: "yes"
  template:
    metadata:
        labels:
          sysbox-install: "yes"
    spec:
      serviceAccountName: sysbox-label-node
      nodeSelector:
          sysbox-runtime: running
      containers:
      - name: sysbox-cleanup-k8s
        image: registry.nestybox.com/nestybox/sysbox-deploy-k8s
        imagePullPolicy: Always
        command: [ "bash", "-c", "/opt/sysbox/scripts/sysbox-deploy-k8s.sh cleanup" ]
        env:
        - name: NODE_NAME
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
        securityContext:
          privileged: false
        volumeMounts:
        - name: host-etc
          mountPath: /mnt/host/etc
        - name: host-dbus
          mountPath: /var/run/dbus
        - name: host-run-systemd
          mountPath: /run/systemd
        - name: host-lib-systemd
          mountPath: /mnt/host/lib/systemd
        - name: host-usr-bin
          mountPath: /mnt/host/usr/bin/
        - name: host-usr-local-bin
          mountPath: /mnt/host/usr/local/bin
        - name: host-run
          mountPath: /mnt/host/run
      volumes:
        - name: host-etc
          hostPath:
            path: /etc
        - name: host-dbus
          hostPath:
            path: /var/run/dbus
        - name: host-run-systemd
          hostPath:
            path: /run/systemd
        - name: host-lib-systemd
          hostPath:
            path: /lib/systemd
        - name: host-usr-bin
          hostPath:
            path: /usr/bin/
        - name: host-usr-local-bin
          hostPath:
            path: /usr/local/bin/
        - name: host-run
          hostPath:
            path: /run
  updateStrategy:
    rollingUpdate:
      maxUnavailable: 1
    type: RollingUpdate
