---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: docker-image-cleanup
  labels:
    tier: management
    app: docker-image-cleanup
spec:
  selector:
    matchLabels:
      name: docker-image-cleanup
  template:
    metadata:
      labels:
        name: docker-image-cleanup
    spec:
      containers:
        - resources:
            requests:
              cpu: "50m"
              memory: "50Mi"
          securityContext:
            privileged: true
          image: critools.azurecr.io/critools:v1
          imagePullPolicy: IfNotPresent
          name: docker-image-cleanup
          command: ["/bin/bash", "-c"]
          args:
            - >
              while true; do
                crictl images -q | xargs -n 1 crictl rmi 2>/dev/null;
                sleep 86400;
              done
          volumeMounts:
            - mountPath: /run/containerd/containerd.sock
              name: docker-volume
      volumes:
        - name: docker-volume
          hostPath:
            path: /run/containerd/containerd.sock
