Skip to content

Image Cleaner DaemonSet

## Image Cleaner DaemonSet Documentation
### Key Features/Components
- Runs as a DaemonSet to ensure one instance per node
- Utilizes Kubernetes downward API for node-specific configurations
- Periodically scans and cleans up unused Docker images
- Configurable thresholds for image age and disk usage
### Step-by-step instructions or configuration details
1. Create a Kubernetes ConfigMap with the necessary configurations:
```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: image-cleaner-config
data:
imageAgeThreshold: "30" # Age of images in days before cleanup
diskUsageThreshold: "80" # Disk usage percentage before cleanup
  1. Deploy the Image Cleaner DaemonSet using the provided manifest:
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: image-cleaner
spec:
selector:
matchLabels:
app: image-cleaner
template:
metadata:
labels:
app: image-cleaner
spec:
containers:
- name: image-cleaner
image: image-cleaner:latest
volumeMounts:
- name: config
mountPath: /config
volumes:
- name: config
configMap:
name: image-cleaner-config
defaultMode: 420

Best practices and recommendations

  • Regularly monitor the logs of the Image Cleaner DaemonSet for any errors or warnings
  • Adjust the image age and disk usage thresholds based on your cluster’s requirements
  • Test the cleanup process in a non-production environment before deploying to production
  • To view the logs of the Image Cleaner DaemonSet:
Terminal window
kubectl logs -n <namespace> <image-cleaner-pod-name>

Common pitfalls and solutions