<p>I was creating a service to cleanup cached/unused images from all the nodes in AKS clusters. The implementation uses &quot;<strong>crictl rmi --prune</strong>&quot;, which deletes all the images which do not have an active pod/container running at the time of trigger i.e., all unused images in cache.</p>
<p>However, I was asked what happens if it deletes images which are required by AKS/K8s, which are currently not in use but might be needed in future? and what if its ImagePullPolicy is set to Never?</p>
<p>So, I had few questions for AKS/K8 experts:</p>
<ul>
<li>I want to know what images are used by AKS/K8s service and in what scenarios?</li>
<li>What is the default ImagePullPolicy for images AKs/k8s might need? &amp;
How can I check if default ImagePullPolicy was changed?</li>
<li>&quot;crictl rmi --prune&quot; is not a recommended way to cleanup cached/unused images? If not,
what is the recommended way to cleanup cached images from
cluster nodes?</li>
</ul>
<p>Apologies if these questions sound silly, still a rookie with K8s :)</p>
<p>Thanks and Regards,</p>
<p>Junaid.</p>

SafiJunaid
<p>That's the right way of cleaning up of old/cached images.
More details here:
<a href="https://github.com/Azure/AKS/issues/1421" rel="nofollow noreferrer">https://github.com/Azure/AKS/issues/1421</a></p>
<p>You can also use a DaemonSet YAML file which can clean-up automatically:
<a href="https://gist.github.com/alexeldeib/2a02ccb3db02ddb828a9c1ef04f2b955" rel="nofollow noreferrer">https://gist.github.com/alexeldeib/2a02ccb3db02ddb828a9c1ef04f2b955</a></p>
<p>/////////////</p>
<p>AKS runs it's images from mcr.microsoft.com repository for all the pods running in kube-system and by-default for those pods imagePullPolicy is &quot;ifNotPresent&quot; and you can't edit/change the policy of the system pods.</p>
<p>//////////</p>
<p>You can see all the pods and its image details in kube-system namespace</p>
<p><strong>Example:</strong></p>
<p>kubectl get pods -n kube-system</p>
<p>(pick up one of the pod from above output, here I am checking kube-proxy pods)</p>
<p>kubectl get pod kube-proxy-cwrqw -n kube-system -o yaml
(From the output you can search for ImagePullPolicy attribute value)</p>
