liveBook · Manning

Image pull policy

As explained in Kubernetes for Developers

An image pull policy is a Kubernetes Pod setting that determines when a container image is pulled from a registry.

An image pull policy tells Kubernetes when to retrieve a container image from a registry. For local development, setting imagePullPolicy to Never prevents remote pulls and makes the Pod use an image already available to the cluster. section 3.4.3

Use the Never policy when deploying a locally built image:

  • Build or load the image into the cluster’s container runtime. section 3.4.3
  • Reference the image by its local name and tag, such as timeserver:latest, without a repository URL. section 3.4.3
  • Set imagePullPolicy: Never in the Deployment’s container specification. section 3.4.3
  • Apply the updated Deployment with kubectl. section 3.4.3
Listing 3.5 Chapter03/3.4.3_LocalDevelopment/deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: timeserver
spec:
  replicas: 3
  selector:
    matchLabels:
      pod: timeserver-pod
  template:
    metadata:
      labels:
        pod: timeserver-pod
    spec:
      containers:
      - name: timeserver-container
        image: timeserver:latest    #1
        imagePullPolicy: Never      #2
#1 Reference to a locally available image
#2 Image pull policy prevents Kubernetes from attempting to fetch this local image remotely.

The Deployment example shows a local image reference alongside imagePullPolicy: Never. section 3.4.3

How Kubernetes for Developers covers it

How deep it goes
Explains the local-image configuration and ErrImageNeverPull failure, but does not compare other pull-policy values.
Examples
Demonstrates timeserver:latest with imagePullPolicy: Never and Minikube image loading.
What it assumes
Assumes a locally built container image and basic Deployment configuration; explains the required image name and policy settings.
What you can do after
Operate local Kubernetes deployments using locally built images and diagnose ErrImageNeverPull when images are unavailable.
How it connects
Connects image pull policy to Deployments, Pods, container registries, Docker, Minikube, and kubectl.

Also explained in

Compare how 2 books explain image pull policy →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kubernetes for Developers. The section links point to the parts of the book it draws on.