I have built a 4 node kubernetes cluster running multi-container pods all running on CoreOS. The images come from public and private repositories. Right now I have to log into each node and manually pull down the images each time I update them. I would like be able to pull them automatically.
- I have tried running docker login on each server and putting the .dockercfg file in /root and /core
- I have also done the above with the .docker/config.json
- I have added secret to the kube master and added imagePullSecrets:
- name: docker.io to the Pod configuration file.
When I create the pod i get the error message Error:
image <user/image>:latest not found
If I log in and run docker pull it will pull the image. I have tried this using docker.io and quay.io.
For centos7, the docker config file is under /root/.dockercfg
Copy and paste result to secret YAML based on the old format:
And it worked for me, hope that could also help.
Kubernetes supports a special type of secret that you can create that will be used to fetch images for your pods. More details here.
To add to what @rob said, as of docker 1.7, the use of .dockercfg has been deprecated and they now use a ~/.docker/config.json file. There is support for this type of secret in kube 1.1, but you must create it using different keys/type configuration in the yaml:
First, base64 encode your
~/.docker/config.json
:Note that the base64 encoding should appear on a single line so with -w0 we disable the wrapping.
Next, create a yaml file:
my-secret.yaml
-
Then, in your pod's yaml you need to reference
registrypullsecret
or create a replication controller:I can confirm that imagePullSecrets not working with deployment, but you can
Add
To the and after
Secrets
, save and exit. And its works. Tested with Kubernetes 1.6.7If you need to pull an image from a private Docker Hub repository, you can use the following.
Create your secret key
secret "myregistrykey" created.
Then add the newly created key to your Kubernetes service account.
Retrieve the current service account
Edit sa.yaml and add the ImagePullSecret after Secrets
Update the service account