-
-
Save subodhp/7a360f62012cc46c9460616fa6146849 to your computer and use it in GitHub Desktop.
crictl image cleanup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: imagecleanupconfig | |
namespace: default | |
labels: | |
component: imagecleanup | |
data: | |
# removes all images unused by a running container | |
cronjobs: 0 0 * * * crictl rmi --prune 2>&1 | |
--- | |
apiVersion: apps/v1 | |
kind: DaemonSet | |
metadata: | |
name: imagecleanup | |
namespace: default | |
spec: | |
selector: | |
matchLabels: | |
component: imagecleanup | |
template: | |
metadata: | |
labels: | |
component: imagecleanup | |
spec: | |
volumes: | |
- name: containerd | |
hostPath: | |
path: /var/run/containerd/containerd.sock | |
type: Socket | |
- name: imagecleanupconfig | |
configMap: | |
name: imagecleanupconfig | |
containers: | |
- name: imagecleanup | |
image: alpine:latest | |
imagePullPolicy: Always | |
env: | |
- name: CRICTL_VERSION | |
value: v1.20.0 | |
- name: CONTAINER_RUNTIME_ENDPOINT | |
value: unix:///var/run/containerd/containerd.sock | |
- name: IMAGE_SERVICE_ENDPOINT | |
value: unix:///var/run/containerd/containerd.sock | |
# details of the command: | |
# - install crictl | |
# - add a cron job from the config map | |
# - execute crond in the foregroud | |
command: | |
[ | |
"sh", | |
"-c", | |
"wget https://github.com/kubernetes-sigs/cri-tools/releases/download/$CRICTL_VERSION/crictl-$CRICTL_VERSION-linux-amd64.tar.gz && tar zxvf crictl-$CRICTL_VERSION-linux-amd64.tar.gz -C /usr/local/bin && crontab /config/cronjobs && crond -f -d 8", | |
] | |
resources: | |
requests: | |
cpu: 100m | |
memory: 50Mi | |
volumeMounts: | |
- name: containerd | |
mountPath: /var/run/containerd/containerd.sock | |
- name: imagecleanupconfig | |
mountPath: /config | |
--- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment