Pull from private gitlab registry fails - x509: certificate is valid for ingress.local, not

Viewed 2861

I'm trying to pull some container in my private gitlab registry but when I try I get the following error:

Failed to pull image "registry.mygitlab.com/name/container-backend:nginx": rpc error: code = Unknown desc = Error response from daemon: Get https://registry.mygitlab.com/v2/: x509: certificate is valid for ingress.local, not registry.mygitlab.com

In the deployment.yml I've added:

imagePullSecrets:
- name: registry-secret

and the registry-secret has been created with:

kubectl create \
—namespace=myns \
secret docker-registry registry2-secret \
--docker-server=registry.mygitlab.com \
--docker-username=myname \
--docker-password=mypassword

One month ago it worked and now it doesnt anymore.. and the credentials are correct :/

1 Answers

Problem lays in TLS certificate on the server, not the login credential on the client. Check if you have following record in daemon.json file:

"insecure-registries" : ["registry.mygitlab.com"]

"Also depending of the registries you are accessing, you may have to perform a "kubectl create secret docker-registry ..." action as explained here. To create secret you should execute command:

$ kubectl create secret docker-registry registry-secret --docker-server=registry.gitlab.com --docker-username=<username> --docker-password=<password> --docker-email=<email

In deployment.yaml file you have used secret named registry-secret not registry2-secret as you have used in command while creating secret -you had created wrong named secret.

Finally, you may have to define the certificate to docker by creating a new directory in /etc/docker/certs.d containing the certificates as explained here.

Take a look: x509-certificate-signed-by-unknown-authority, create-a-secret-that-holds-your-authorization-token.

Also take a look: gitlab-tls.

Related