Kubernetes:如何自动清理未使用的图像 [英] Kubernetes: How to automatically clean up unused images

查看:70
本文介绍了Kubernetes:如何自动清理未使用的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某些内部问题,我们需要在未使用的图像一经使用就立即将其删除.
我确实知道可以使用垃圾收集,但是没有提供我们需要的严格政策. 我遇到过解决方案,但是

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. 已弃用
  2. 它还删除了容器和可能的已装载卷

我正在考虑直接在节点上设置cron作业以运行docker prune,但我希望有更好的方法

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

不知道它是否会有所作为,但我们正在使用AKS

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

推荐答案

这并不能真正起到很大作用,因为如果再次请求,它们将被重新下载.但是,如果您坚持要愚蠢的话,最好的选择是DaemonSet,它与安装在主机docker control socket hostPath上的主机一起运行,并运行您提到的docker system prune.您不能使用cron作业,因此您需要自己编写循环,可能只是bash -c 'while true; do docker system prune && sleep 3600; done'之类的东西.

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.

这篇关于Kubernetes:如何自动清理未使用的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆