<p>I have a cluster to manage which has Pods running with Image-CachePolicy set to &quot;<code>IfNotPresent</code>&quot;.</p>
<pre><code>containers:
  - name: test-app
    image: myimages/test-app
    imagePullPolicy: &quot;IfNotPresent&quot;
</code></pre>
<p>I am already familiar with the difference between <code>IfNotPresent</code> and <code>Always</code>.</p>
<p>In our case, if the Pod gets respawned, K8s will due to &quot;IfNotPresent&quot; load the image from some cache instead of fetching the image from docker-hub.</p>
<p>What we want to achieve is to find this place where kubectl is caching the image and delete the cache in order to make K8s re-fetching the image on the next time, when the Pod gets restarted.</p>
<p>We <strong>don't want</strong> to apply a new Policy with <code>imagePullPolicy</code> set to <code>Always</code> because this would already fetch the latest version of the Pod, which we don't want yet. Instead, it shall only fetch new newest image on the next restart of the pod.</p>
<p>Is there any way to do this? Where to find this caching-location?</p>

MrsBookik
<p>If you imagined Kubernetes was running Docker, it'd do the equivalent of:</p>
<ol>
<li>Look at <code>docker images</code>.</li>
<li>If the image isn't already there, <code>docker pull</code> it.</li>
<li><code>docker run</code> the resulting image.</li>
</ol>
<p>(<code>imagePullPolicy: Always</code> skips the first step and always pulls the image; <code>Never</code> skips the pull, and will fail if the image isn't already there.)</p>
<p>Each node will have its own copy of the images; where exactly depends on the specific container runtime in use.  Each node in turn knows how to <a href="https://kubernetes.io/docs/concepts/cluster-administration/kubelet-garbage-collection/" rel="nofollow noreferrer">garbage collect images not currently in use</a>, though old images will generally stick around until the local disk fills up (or until a tool like the cluster autoscaler deletes the node).</p>
<p>A general assumption in Kubernetes is that a given <code>registry.example.com/name/image:tag</code> string uniquely identifies an image.  Your CI/CD system should cooperate with this, and assign a distinct tag to each image build (maybe based on the commit ID or a date stamp).  If you do this, you shouldn't need to adjust <code>imagePullPolicy:</code> from its default or try to manually remove images from nodes.</p>
