kubernetesnetwork-programmingdocker-registrycoredns

Kubernetes - Failed to Pull image - no such how


We are taking the step to upgrade our infrastructure setup and are doing some R&D with K8s.

We believe k8s is the solution we want to implement, however I've hit a brick wall.

I'm really struggling to get k8s to pull an image from a private registry that uses a hostname that does not exist.

I have followed instructions online and have successfully added a host record to coredns - I have verified it resolves correctly using throwaway containers, yet it seems like whenever I try to pull an image, I get the same error:

Failed to pull image "fake.host.uk/app": rpc error: code = Unknown desc = Error response from daemon: Get "https://fake.host.uk/v2/": dial tcp: lookup fake.host.uk: no such host

Doing a docker login fake.host.uk works absolutely fine. I can also see my added hosts via

kubectl run -it --rm --restart=Never --image=infoblox/dnstools:latest dnstools

Then running ping fake.host.uk brings back the correct IP.

However, trying to pull an image just doesn't work; how can I solve this problem?


Solution

  • DNS resolution needs to be setup for each node in your cluster, preferably by updating a common DNS server, but you can also update /etc/hosts on every node in the cluster. Kubernetes and docker pull images from the node and not from within a container, so they won't see the settings applied to things like coredns (it would create a circular dependency, how do you resolve the name of the coredns image's registry).