Course contentsShow
← Cloud and Infrastructure
Lesson 1271 of 2,98925. Kubernetes Configuration and SecretsFree lesson

ImagePullSecrets for Private Registries

Use dockerconfigjson Secrets to authenticate Pods with private container registries.

ImagePullSecrets for Private Registries

What You'll Learn

You'll learn how to authenticate Kubernetes Pods with private container registries using special dockerconfigjson Secrets.


Why Private Registries Need Authentication

When you pull container images from public registries like Docker Hub, no credentials are required. But production workloads often use private registries (AWS ECR, Google GCR, Azure ACR, or self-hosted) that require authentication. Think of it like a private library—you need a library card (credentials) to check out books (pull images).

Without proper authentication, your Pod will fail with an ImagePullBackOff error when Kubernetes tries to fetch the image.

How ImagePullSecrets Work

An ImagePullSecret is a special type of Secret (kubernetes.io/dockerconfigjson) that stores registry credentials in the same format Docker uses. When you reference this Secret in a Pod specification, Kubernetes automatically authenticates with the private registry before pulling images.

Creating an ImagePullSecret

kubectl create secret docker-registry my-registry-secret \
  --docker-server=registry.example.com \
  --docker-username=myuser \
  --docker-password=mypassword \
  --docker-email=user@example.com

Using the ImagePullSecret in a Pod

apiVersion: v1
kind: Pod
metadata:
  name: private-app
spec:
  containers:
  - name: app
    image: registry.example.com/private/myapp:v1
  imagePullSecrets:
  - name: my-registry-secret

The imagePullSecrets field tells Kubernetes which Secret contains registry credentials. Multiple Secrets can be listed if you use images from different registries.


Key Takeaway:
ImagePullSecrets are dockerconfigjson type Secrets that allow Kubernetes to authenticate with private container registries—essential for pulling private images into your Pods.