Inferensys

Glossary

Image Pull Policy

An Image Pull Policy is a Kubernetes pod specification that dictates when the container runtime should pull a container image from a registry.
Compute infrastructure aisle representing runtime, scale, and model serving.
KUBERNETES DEPLOYMENT

What is Image Pull Policy?

A Kubernetes configuration that controls the container runtime's image caching and update behavior.

An Image Pull Policy is a directive in a Kubernetes pod specification that dictates when the container runtime should download a container image from a registry. The three primary policies are Always, IfNotPresent, and Never. This setting is crucial for managing deployment speed, network efficiency, and ensuring pods run the intended image version, directly impacting agent deployment observability and rollout consistency.

The IfNotPresent policy (the default if the image tag is :latest or unspecified) pulls the image only if it isn't already cached locally, optimizing for speed. The Always policy forces a pull on every pod creation, essential for guaranteeing the latest image in continuous deployment pipelines. The Never policy assumes the image is pre-loaded, used in air-gapped or highly controlled environments. Incorrect configuration can lead to stale image deployment or unnecessary registry load.

KUBERNETES DEPLOYMENT

Core Image Pull Policy Values

The imagePullPolicy is a directive in a Kubernetes pod specification that controls the container runtime's behavior for fetching container images from a registry. It is a critical setting for managing deployment speed, network usage, and ensuring deterministic image versions in production.

01

Always

The Always policy instructs the kubelet to pull the image from the container registry every time a pod is started or restarted. This is the default policy when:

  • Using the :latest tag.
  • The image tag is omitted.

Key Use Cases:

  • Development & CI/CD: Ensures the absolute latest build is always used.
  • Security: Guarantees the node always fetches an image, which can be combined with registry authentication and vulnerability scanning on pull.

Considerations:

  • Increases deployment latency due to network I/O.
  • Can cause version indeterminism if the :latest tag is mutable.
  • Consumes more network bandwidth.
02

IfNotPresent

The IfNotPresent policy tells the kubelet to pull the image only if it is not already present on the node. This is the default policy for all images with a specific tag other than :latest.

Key Use Cases:

  • Production Stability: Favors speed and reduces external dependencies by using cached images.
  • Air-Gapped/Offline Environments: Essential for clusters with limited or no external registry access.
  • Bandwidth Conservation: Minimizes network traffic to the registry.

Considerations:

  • Nodes may run stale images if the cache is not manually cleared.
  • Requires a separate image update process (e.g., node recycling) for cluster-wide rollouts of a new image with the same tag.
03

Never

The Never policy instructs the kubelet to never pull an image. It will only start a container if the specified image is already present locally on the node.

Key Use Cases:

  • Disconnected/High-Security Clusters: Where all container images are pre-loaded onto nodes via secure, offline processes.
  • Testing with Custom Local Builds: Using images built directly on the node during development.
  • Deterministic Binary Artifacts: Treating container images as immutable, pre-vetted binaries deployed via cluster management tooling.

Considerations:

  • Pod scheduling is constrained to nodes that already have the image.
  • Image updates require a deliberate, node-level orchestration process outside of standard Kubernetes deployments.
04

Interaction with Image Tags

The image tag directly influences the default pull policy, creating a crucial link between image versioning and deployment behavior.

Default Behavior Matrix:

  • Image with tag :latest or no tag: Defaults to Always.
  • Image with any other tag (e.g., v1.2.3, sha256:abc123): Defaults to IfNotPresent.

Best Practices:

  • Use Immutable Tags: Prefer cryptographically secure, immutable identifiers like SHA256 digests (e.g., myapp@sha256:abc123...). This combines the safety of a unique image with the speed of IfNotPresent.
  • Avoid :latest in Production: The mutable :latest tag can lead to unpredictable rollouts and makes rollbacks difficult.
  • Explicit Overrides: Always explicitly set the imagePullPolicy in production manifests to avoid reliance on default behaviors.
05

Agent Deployment & Observability Impact

For Agent Deployment Observability, the pull policy is a key lever controlling rollout determinism and telemetry consistency.

Observability Implications:

  • Rollout Speed: IfNotPresent leads to faster pod startups on nodes with cached images, improving perceived agent availability.
  • Version Consistency: Using Always with mutable tags can cause a mixed-version deployment during a rollout, complicating performance benchmarking and anomaly detection.
  • Failure Diagnosis: Pods stuck in ImagePullBackOff status indicate a failed pull due to policy Always or IfNotPresent with a missing image. This is a critical signal for deployment health.

Recommended Pattern for Agents:

  1. Build agent images with immutable tags (Git SHA).
  2. Set imagePullPolicy: IfNotPresent.
  3. Use a DaemonSet with a RollingUpdate strategy.
  4. Force a pull of the new image by deleting pods or using a tool that updates the pod template, causing new pods to be created with the new image reference.
06

Related Kubernetes Concepts

The image pull policy interacts with several other core Kubernetes features for robust deployments.

Image Pull Secrets: The imagePullPolicy governs when to pull, while imagePullSecrets provide the credentials for pulling from private registries. Both must be correctly configured.

Node Selection & Affinity: The Never policy makes node image caching a critical scheduling constraint. You may need to use nodeName or nodeSelector to target pre-loaded nodes.

Pod Lifecycle: The pull attempt occurs during the container creation phase. Failures here are reflected in pod events and statuses (ErrImagePull, ImagePullBackOff).

Runtime Class: Advanced use cases may use different container runtimes (e.g., gVisor, Kata Containers) which all respect the standard imagePullPolicy.

Init Containers: Each init container can have its own imagePullPolicy, allowing flexible staging of prerequisite images.

KUBERNETES POD SPECIFICATION

How It Works: Mechanism and Interactions

An Image Pull Policy is a directive within a Kubernetes pod specification that controls the container runtime's behavior for fetching container images from a registry.

The policy is defined per container in a pod spec via the imagePullPolicy field. Its primary mechanism is to instruct the kubelet on the worker node when to initiate a pull operation against a configured container image registry. The three canonical values are Always, IfNotPresent, and Never. This setting directly interacts with the local container runtime's image cache, determining whether a remote registry check is required before container startup.

Its interaction with other systems is critical for deployment observability. During a rolling update, the policy governs whether a node uses a cached image or fetches the latest tagged version, affecting rollout consistency. It works in conjunction with image tags and digests; using the :latest tag with IfNotPresent can lead to stale deployments. For deterministic agent deployments, a policy of Always paired with immutable image digests ensures every pod restart pulls the exact, audited build.

KUBERNETES DEPLOYMENT

Image Pull Policy Comparison

A comparison of the three primary Kubernetes image pull policies, detailing their behavior, use cases, and operational impact on container deployment.

Policy FeatureAlwaysIfNotPresentNever

Default Pull Behavior

Pulls the image from the registry on every pod startup.

Pulls only if the image is not present on the node.

Never pulls an image; relies solely on a pre-pulled image on the node.

Tag-Based Behavior

Always pulls, even for ':latest' or immutable tags.

Treats ':latest' tag as 'Always'; uses local cache for other tags.

Always uses local image, regardless of tag.

Use Case

Guarantees the absolute latest image version; critical for CI/CD with mutable tags.

Optimizes for startup speed and reduces registry load; standard for production with versioned tags.

Air-gapped environments, local development, or when registry access is restricted.

Network Dependency

High. Requires registry access on every pod (re)start.

Medium. Requires registry access only for the first pull per node.

None. No registry access required after initial image load.

Startup Latency

Highest. Includes full image pull time on every restart.

Lowest after first pull. Subsequent starts use cached image.

Lowest. No pull overhead, but depends on pre-existing image.

Security & Consistency

Ensures deployment of the latest, potentially patched, image from the registry.

Risk of node-level image drift if cached images are not updated.

Highest risk of drift; requires manual image management across the cluster.

Registry Cost Impact

Highest. Generates pull requests on every pod lifecycle event.

Low. Pulls are amortized across multiple pods on a node.

None after initial cluster seeding.

Recommended For

Development with mutable tags, canary deployments where image changes frequently.

General production deployments with immutable semantic version tags (e.g., 'app:v1.2.3').

Highly controlled or offline environments with strict image governance.

IMAGE PULL POLICY

Frequently Asked Questions

A Kubernetes **Image Pull Policy** is a pod specification that dictates when the container runtime should pull a container image from a registry. It is a critical configuration for managing deployments, caching, and security in containerized environments.

An Image Pull Policy is a directive in a Kubernetes pod specification that controls the container runtime's behavior for fetching a container image. It determines whether the runtime should always pull the latest image, only pull if a cached version is not present, or never pull an image at all. This policy is defined per container within a pod using the imagePullPolicy field and is essential for managing image updates, ensuring consistency, and controlling network traffic to container registries.

The three primary policies are:

  • Always: The runtime pulls the image from the registry every time the pod starts.
  • IfNotPresent: The runtime only pulls the image if it is not already present locally on the node.
  • Never: The runtime will never pull the image and assumes it already exists locally.

This configuration is a foundational element of Agent Deployment Observability, as it directly impacts which version of an agent's code is executed, affecting rollout behavior and the validity of canary or A/B test results.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.