How to configure Kubernetes to pull images from a private Docker registry
How to configure Kubernetes to pull images from a private Docker registry:
- First configure Docker by following the steps outlined here:
- Verify that the Docker configuration contains the authentication information
sudo cat ~/.docker/config.json
{
"auths": {
"<registry-server>": {
"auth": "<hash>"
}
},
"HttpHeaders": {
"User-Agent": "Docker-Client/18.09.4 (linux)"
}
}
- Base64 encode the config.json file
cat ~/.docker/config.json | base64 -w0 > config.base64.json
- Create secret.yml and add the contents of config.base64.json to dockerconfigjson
apiVersion: v1
kind: Secret
metadata:
name: registrypullsecret
data:
.dockerconfigjson: <config.base64.json>
type: kubernetes.io/dockerconfigjson
- Import the secret into Kubernetes
kubectl create -f secret.yml && kubectl get secrets
- Test that the secret was imported into Kubernetes
kubectl get secrets