Cloud Native 4 min read

Accelerating Kubernetes Image Pulls

To reduce pod startup delays caused by slow image downloads, this article explains Kubernetes image pull policies, the impact of image size, network transfer, and caching strategies such as using smaller base images, docker‑slim, pre‑pulling via DaemonSets, and the cluster’s garbage‑collection thresholds.

System Architect Go
System Architect Go
System Architect Go
Accelerating Kubernetes Image Pulls

Kubernetes pods pull the user‑specified container image when they start; if this process takes too long, pods remain in a pending state and cannot serve requests promptly.

The image pull workflow is illustrated in the figure below:

The pod's imagePullPolicy has three possible values:

IfNotPresent : Pull the image only when it does not already exist on the node.

Always : The kubelet compares the image digest; if a cached copy exists it is used, otherwise the image is pulled from the registry.

Never : Use only a local image; if the image is missing the pod fails to start.

Note: each image digest is unique, although tags can be overwritten.

From the pull process we can accelerate image retrieval in three main ways:

Reduce image size: use a smaller base image, remove unnecessary dependencies, minimize the number of layers, employ multi‑stage builds, or use tools like docker-slim .

Speed up network transfer between the image registry and Kubernetes nodes.

Proactively cache images: pre‑pull images (Pre‑pulled) so they are available locally, for example by running a DaemonSet that periodically syncs registry images to each node.

Side note 1: How long do locally cached images stay on disk, and do they cause storage issues?

Cached images occupy node disk space; the more images cached, the more storage they consume. By default, cached images persist indefinitely because there is no TTL mechanism.

However, Kubernetes' garbage‑collection (GC) automatically cleans up images. When node disk usage exceeds the HighThresholdPercent (default 85%), GC is triggered; the kubelet then removes the oldest unused images until usage falls below the LowThresholdPercent (default 80%).

Side note 2: Is having fewer image layers always better?

While fewer layers can reduce image size, it can be counter‑productive in some scenarios. Large RUN commands create a single massive layer that must be rebuilt entirely when any part changes, losing cache benefits. Moreover, layers are transferred concurrently during upload/download, whereas a single large layer cannot be streamed in parallel.

performanceCloud NativeKubernetescachingContainerImage Pull
System Architect Go
Written by

System Architect Go

Programming, architecture, application development, message queues, middleware, databases, containerization, big data, image processing, machine learning, AI, personal growth.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.