kubernetes: Failed to pull image with "x509: certificate signed by unknown authority" error
BUG REPORT
Kubernetes version :
Client Version: version.Info{Major:“1”, Minor:“5”, GitVersion:“v1.5.2”, GitCommit:“08e099554f3c31f6e6f07b448ab3ed78d0520507”, GitTreeState:“clean”, BuildDate:“2017-01-12T04:57:25Z”, GoVersion:“go1.7.4”, Compiler:“gc”, Platform:“linux/amd64”}
Server Version: version.Info{Major:“1”, Minor:“5”, GitVersion:“v1.5.2”, GitCommit:“08e099554f3c31f6e6f07b448ab3ed78d0520507”, GitTreeState:“clean”, BuildDate:“2017-01-12T04:52:34Z”, GoVersion:“go1.7.4”, Compiler:“gc”, Platform:“linux/amd64”}
Environment:
- Cloud provider or hardware configuration:
- OS: CentOS Linux 7
- Kernel: Linux kubernetes-master-3302 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
What happened:
I used the below command to create a POD:
kubectl create --insecure-skip-tls-verify -f monitorms-rc.yml
I get this monitorms-mmqhm 0/1 ImagePullBackOff
and upon running
kubectl describe pod monitorms-mmqhm --namespace=sample
It said Warning Failed Failed to pull image "10.78.0.228:5000/monitorms": Error response from daemon: {"message":"Get https://10.78.0.228:5000/v1/_ping: x509: certificate signed by unknown authority"}
There is no certificate mentioned anywhere in my deployment configuration anywhere.
10.78.0.228 is running a private insecured docker registry. Should Kubernetes not ignore the server certificate with that --insecure-skip-tls-verify flag ?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 42 (13 by maintainers)
You would think that this is solved by now.
CA Certificates
Actual recorded cases of preventing unauthorized access : ZERO Amount of countless of developer time wasted because of tooling that don’t integrate CA certs into their tooling properly: gasmillions of man hours.
Moral of the story. Ditch CA certs. Such a ballache every time you have try to get tooling to work together. Nobody knows how it works. Nobody. Software that use it never work. In the end you just copy all the certs to every machine and your toaster just so you don’t get that god damn x509: certificate signed by unknown authority bullshit error every bloody time you try to do any tooling.
Now I have to go and drill right to the core of this cluster to get those certs installed, because kubernetes’s secrets for handling docker is just plain useless.
Just use the money that would have been spent trying to get the bloody CA certs to work and hire a henchman with an axe that cut the hardlines when the hacker comes. This CA certs it’s not security if it does not let authorized people in because the entire field is just one giant BUG that will JAM your tooling.
@srossross-tableau
As far as I remember this was a docker issue, not a kubernetes one. Docker does not use linux’s ca certs. Nobody knows why.
You have to install those certs manually (on every node that could spawn those pods) so that docker can use them:
/etc/docker/certs.d/mydomain.com:1234/ca.crt
This is a highly annoying issue as you have to butcher your nodes after bootstrapping to get those certs in there. And kubernetes spawns nodes all the time. How this issue has not been solved yet is a mystery to me. It’s a complete showstopper IMO.
This should really be solved using the secrets mechanism of kubernetes. But somehow it is not. Who knows!?
should anyone face it while using directly the gcr.io, one possible situation is that CA certificates on your machine are too old.
solution that worked for me on RH/CentOS:
@rushilpaul
--insecure-skip-tls-verify
is not a valid argument forkubectl create
;x509 error
is ondocker
side. The daemon failed to pull image from that insecure registry. You can refer to insecure docker registry on how to trust/skip the registry security.2020 and still the same issue. private harbor registry. docker pull works with no problem. ls /etc/docker/certs.d/registry.myharbor.com/ shows up the certificate. kubernetes fails to pull images with imagepullbackoff error. It is 3 years and kubernetes still has this issue. Very disappointing.
@unixoff THANKS.
I did this a gazzilion times:
when I did this it worked:
Don’t forget to execute after changes
working solution for pulling docker image on ubuntu from Artifactory (certificate is selfsigned):
That is a valid arg to
kubectl create
but just controls trust between kubectl and the API serverThe pull error is between the node and the docker registry. The node either needs to trust the certificate or treat that registry as an untrusted registry (which makes the node tolerate TLS verification errors)
These commands work for me, run them on all nodes include master node
Ref: https://docs.docker.com/registry/insecure/#docker-still-complains-about-the-certificate-when-using-authentication
for x509: certificate signed by unknown authority
https://gitlab.com/stirumala/kubernetes/-/blob/main/findings.txt
I am working in my local dev environment
I am using Jfrog Container Registry as registry to my minikube. I am able do the following:
I have configured Jfrog Container Registry to run behind Nginx Reverse Proxy listening on port 443. Created self-signed certs and Jfrog is using these certs.
Configured docker to use the self-signed certs as follows.
Configure K8 to use the docker login secret by .yaml file as following:
In the deployment.yaml, I use ImagePullSecrets and the name flag.
Now after all this setup where the docker pull is working on terminal, I get error on the pods saying x509 IP Sans.
I went through lot of documentation and K8 issues, replicated the step of https://github.com/kubernetes/kubernetes/issues/43924#issuecomment-631533150
replicated the steps didn’t work out. Can anyone let me know what I am doing wrong? and how can I correct it.
Paste the entire folder name in ‘/etc/docker/certs.d/’ please. And the filenames of the certs.
It should work if all your nodes have that cert installed.
--insecure-skip-tls-verify
just skips the server’s certificate verification, not docker registry, so it can not solve the problem. The error is from Docker daemon while pulling image.Maybe you should try the command
docker pull 10.78.0.228:5000/monitorms
on the k8s nodes which hold the pod, not the k8s master.No one really spelled out how to fix this. Here is what I did
My env:
cd /etc/docker/certs.d/
, create a directory in here that uses the SAME EXACT name used when you communicate with the registry in your manifest. So if you are referecing “docker-reg.company.domain” directory must say that. Or if you use “docker-reg.company.domain:443”, need to make the directory name include the port. Must be exact as you reference in your mainfest.Debian / Ubuntu
cp certs/domain.crt /usr/local/share/ca-certificates/myregistrydomain.com.crt
update-ca-certificates
Rhel / Centoscp certs/domain.crt /etc/pki/ca-trust/source/anchors/myregistrydomain.com.crt
update-ca-trust
docker pull docker-reg.company.domain:443/my-image:latest
(Or however you have it in your manifest, must be exact)If all this is done correctly try doing a deployment with kubectl again. Be careful of namespaces.
I run kubernetes on RancherOS as part of Rancher 2.x setup and have private registry that is not internet facing, so I have to use self-signed certificate on it, resulting in x509 error. I read this thread and few others and the solved the issue - sharing in case it may help someone, if not directly then by suggesting possible path.
This worked for me - https://www.ctrl-alt-del.cc/2018/11/solution-rancher-2-k8s-private-registry.html