Kubernetes: How to automatically clean up unused images

笑着哭i 提交于 2021-02-19 07:35:49

问题


Due to some internal issues, we need to remove unused images as soon as they become unused.
I do know it's possible to use Garbage collection but it doesn't offer strict policy as we need. I've come across this solution but

  1. it's deprecated
  2. it also removes containers and possible mounted volumes

I was thinking about setting a cron job directly over the nodes to run docker prune but I hope there is a better way

No idea if it makes a difference but we are using AKS


回答1:


This doesn't really accomplish much since things will be re-downloaded if they are requested again. But if you insist on a silly thing, best bet is a DaemonSet that runs with the host docker control socket hostPath-mounted in and runs docker system prune as you mentioned. You can't use a cron job so you need to write the loop yourself, probably just bash -c 'while true; do docker system prune && sleep 3600; done' or something.



来源:https://stackoverflow.com/questions/58596782/kubernetes-how-to-automatically-clean-up-unused-images

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!