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 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.
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 get image connection FATA 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
# 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