[Kubernetes]: failed to pull image registry.k8s.io/kube-apiserver:v1.27.1

Updated on September 5, 2023

While installing Kubernetes and configuring Kubernetes on the Master node, encountered the error “failed to pull image registry.k8s.io/kube-apiserver:v1.27.1”. Below is the complete error message:

# kubeadm config images pull
failed to pull image "registry.k8s.io/kube-apiserver:v1.27.1": output: time="2023-07-19T05:36:01Z" level=fatal msg="validate service connection: CRI v1 image API is not implemented for endpoint \"unix:///var/run/containerd/containerd.sock\": rpc error: code = Unimplemented desc = unknown service runtime.v1.ImageService"
, error: exit status 1
To see the stack trace of this error execute with --v=5 or higher

Kubernetes Information:

Kubernetes version: v1.27.1
Host OS: CentOS 8

How to solve failed to pull image registry.k8s.io?

Solution: The error message “failed to pull image registry.k8s.io/kube-apiserver:v1.27.1” typically indicates that Kubernetes was unable to download the specified image “kube-apiserver:v1.27.1” from the container registry “registry.k8s.io”. Kubernetes uses registry.k8s.io as the default repository for downloading images.

Step 1: Verify your network connections.

If you are behind the proxy, setup your HTTP_PROXY settings properly and verify the connection is able to reach registry.k8s.io

Step 2: Kubernetes uses crictl, a command-line interface for CRI-compatible container runtimes.

Important to know

Starting from Kubernetes v1.22, Docker is no longer supported as a container runtime or even a tool to manage containers and images. As alternatives, containerd will be used as container runtime and crictl will be used as CLI for CRI (Container Runtime Interface). It provides various debugging capabilities for Kubernetes which are very similar to Docker’s command line interface. It can be used with any container runtime that supports CRI, such as Docker and containerd.

Configure crictl based on the container runtime (containerd) installed in your system. Crictl uses /etc/crictl.yaml config file. If the file doesn’t exist, create the file and add the below contents. If the file already exists, verify the contents below:

# vim /etc/crictl.yaml
# these first two endpoint setting is where you configure crictl to containerd
runtime-endpoint: unix:///run/containerd/containerd.sock
image-endpoint: unix:///run/containerd/containerd.sock
timeout: 2
debug: true
pull-image-on-create: false

Step 3: Verify the correct working of crictl, but still I got the below error message. This error occurs if CRI is not configured properly.

# crictl pull ubuntu
DEBU[0000] get image connection
FATA[0000] validate service connection: CRI v1 image API is not implemented for endpoint "unix:///run/containerd/containerd.sock": rpc error: code = Unimplemented desc = unknown service runtime.v1.ImageService

Step 4: Configure containerd as the node’s runtime. Enable the CRI interface by commenting out the disabled_plugins line in /etc/containerd/config.toml config file and restart the containerd service.

# disabled_plugins = ["cri"]

If the file /etc/containerd/config.toml doesn’t exist, generate a new default configuration file.

# containerd config default > /etc/containerd/config.toml
Containter Runtime

Containter Runtime is a fundamental component that empowers Kubernetes to run containers effectively. It is responsible for managing the execution and lifecycle of containers within the Kubernetes environment. Kubernetes has been setup to use containerd as container runtimes.

# systemctl restart containerd

Now the underlying Container Runtime is configured properly. Continuing with Kubernetes configuration…

# kubeadm config images pull
[config/images] Pulled registry.k8s.io/kube-apiserver:v1.27.1
[config/images] Pulled registry.k8s.io/kube-controller-manager:v1.27.1
[config/images] Pulled registry.k8s.io/kube-scheduler:v1.27.1
[config/images] Pulled registry.k8s.io/kube-proxy:v1.27.1
[config/images] Pulled registry.k8s.io/pause:3.9
[config/images] Pulled registry.k8s.io/etcd:3.5.9-0
[config/images] Pulled registry.k8s.io/coredns/coredns:v1.10.1

Was this article helpful?

Related Articles

Leave a Comment