我正在使用 Kubernetes 部署 Azure Kubernetes 服务提供的所有微服务。
每当我发布上个月以来频繁发布的微服务更新时,它都会从 Azure 容器注册表中提取新镜像。
我试图弄清楚这些图像驻留在集群中的什么位置?
就像 Docker 存储一样,在/var/lib/docker 中提取镜像,并且由于 Kubernetes 在底层使用 Docker,它也可能将镜像存储在某个地方。
但是如果是这种情况,如何从集群中删除不再使用的旧镜像?
最佳答案
在 Kubernetes v1.19 或更高版本上创建的具有 Linux 节点池的集群默认使用 containerd 作为其容器运行时 ( Container runtime configuration )。
手动删除运行容器的节点上未使用的镜像:
身份节点名称:
kubectl get nodes
在节点 ( Connect with SSH to Azure Kubernetes Service ) 上启动交互式调试容器:
kubectl debug node/aks-agentpool-11045208-vmss000003 -it --image=mcr.microsoft.com/aks/fundamental/base-ubuntu:v0.0.11
在调试容器 ( check for newer releases of crictl ) 上设置 crictl
:
The host node's filesystem is available at
/host
, so configurecrictl
to use the host node'scontainerd.sock
.
curl -sL https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.23.0/crictl-v1.23.0-linux-amd64.tar.gz | tar xzf - -C /usr/local/bin \
&& export CONTAINER_RUNTIME_ENDPOINT=unix:///host/run/containerd/containerd.sock IMAGE_SERVICE_ENDPOINT=unix:///host/run/containerd/containerd.sock
删除节点上未使用的图像:
crictl rmi --prune
关于image - 从 Azure 容器注册表拉取后,镜像存储在 Azure Kubernetes 集群中的何处?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55035858/