Search code examples
dockerkubernetesregistrydocker-registry

Kubernetes with private docker registry v2


I am trying to setup a private docker registry to work with Kubernetes. I've setup the registry and the master-server thats running the Kubernetes cluster can pull images from the registry without a problem. Also, I've followed the docs of Kubernetes that explain how to connect to a private docker registry (see https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/).

However, when I try to pull images from the docker registry through Kubernetes I get the following error:

Failed to pull image "xxx.xxx.xxx.xxx:5000/helloworld:latest": rpc error: code = Unknown desc = Error response from daemon: Get https://xxx.xxx.xxx.xxx:5000/v1/_ping: x509: certificate signed by unknown authority

What I noticed is that the link that ends with v1/_ping is incorrect, it should be v2/_ping.

I ran the following command to generate my regcred:

kubectl create secret docker-registry regcred --docker-server="https://xxx.xxx.xxx.xxx:5000/v2/" --docker-username=xxxxx --docker-password=xxxxxx [email protected]

I also googled a bit and found this: https://github.com/kubernetes/kubernetes/issues/20786

These suggestions, unfortunately, it didn't help, but they do indicate that more people face the same issue.

Does someone know how to correctly setup a docker registry v2 with Kubernetes?

Thanks


Solution

  • Solved this issue, the master-server by default doesn't launch your deployments. So I needed to do the following at my slave servers:

    1. Add the certificate to /etc/docker/certs.d/my-registry-domain.com[:port]/ca.crt
    2. Do docker login my-registry-domain.com[:port]
    3. Add the docker registry secret to Kubernetes (see https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/) --docker-server=docker-registry-domain.com/v2/ or v1 depending on what you run
    4. Now it will successfully pull images from the docker registry.

    Hope it will help someone.