Kubernetes is deprecating Docker

Ranjeet Jadhav
4 min readMar 13, 2021

--

Kubernetes cluster setup with containerd runtime

In this blog, we will see the only implementation of containerd in the Kubernetes cluster. As there are lots of links available on the reason behind Kubernetes deprecating the docker.

google

As we know Kubernetes is deprecating the docker in the upcoming release later in 2021, we should know how to set up the Kubernetes cluster using the containerd. As containerd is the second most popular container runtime.

The Kubernetes will only deprecate the container runtime interface. Docker produced images will still continue to work in your cluster with all runtimes, as they always have. There is no need to worry about which container images, which container registry, which tool should I use to build the container Images. Docker is still a useful tool for building containers, and the images that result from running docker build can still run in your Kubernetes cluster.

What you will need:

One ubuntu Desktop/server 16/18.04 with sudo access:

Implementation:

Steps to install containerd runtime environment

Use the below command to install containerd on the Ubuntu server:

#sudo apt-get update

#sudo apt-get install containerd -y

Configure containerd using below commands:

#sudo mkdir -p /etc/containerd

#sudo su -

#containerd config default /etc/containerd/config.toml

Steps to install kubernetes packages:

To add the gpg-key:

#curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -

To add the repo:

#echo ‘deb http://apt.kubernetes.io/ kubernetes-xenial main’ | sudo tee /etc/apt/sources.list.d/kubernetes.list

#apt-get update -y

To install Kubernetes related packages:

#apt-get install kubelet kubeadm kubectl -y

After installing the docker we don’t need to do any additional configuration as it does automatically. But after installing containerd we have to do some manual configuration using the below commands to load modules requires for containerd:

#sudo cat <<EOF | sudo tee /etc/modules-load.d/containerd.conf

overlay

br_netfilter

EOF

#sudo modprobe overlay

#sudo modprobe br_netfilter

Setup required sysctl parameters, these persist across reboot:

#cat <<EOF | sudo tee /etc/sysctl.d/99-kubernetes-cri.conf

net.bridge.bridge-nf-call-iptables = 1

net.ipv4.ip_forward = 1

net.bridge.bridge-nf-call-ip6tables = 1

EOF

Apply sysctl parameters without reboot:

#sudo sysctl — system

Configure Kubernetes cluster for using containerd runtime environment:

User below command to initialize the kubernetes cluster:

#sudo kubeadm init — cri-socket /run/containerd/containerd.sock — pod-network-cidr=10.244.0.0/16

#sudo mkdir -p $HOME/.kube

#sudo cp -rf /etc/kubernetes/admin.conf $HOME/.kube/config

#sudo chown $(id -u):$(id -g) $HOME/.kube/config

Deploy pod network using below command:

#sudo kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

The below fig. shows command output that indicates Kubernetes cluster is configured with containerd runtime environment:

#kubectl get nodes -owide

Verify kube-system pod running or not using the below command:

Congratulations, We have successfully configured the Kubernetes cluster using containerd runtime.

Deploy Nginx web server in this containerd runtime environment Kubernetes cluster using the docker image.

Important:

In this blog, To operate containers and images in containerd runtime environment Kubernetes clusters, we will use crictl command-line tools. The images pulled by using the docker command will not run in the Kubernetes cluster. You have to pull docker images using crictl command then and then the only docker created images will run in the Kubernetes cluster created by using the containerd runtime environment. Crictl command has come already after installation of containerd in our machine.

To work with crictl command line tool fire below command

#sudo cat <<EOF > /etc/crictl.yaml

runtime-endpoint: unix:///var/run/containerd/containerd.sock

image-endpoint: “”

timeout: 0

debug: false

EOF

Check docker images present on your machine using the below command:

#sudo crictl images

To pull Nginx docker image use below command

#sudo crictl pull nginx

Use the below deployment file to deploy the Nginx web server.

#cat <<EOF > nginx.yaml

apiVersion: apps/v1

kind: Deployment

metadata:

name: nginx-deployment

labels:

app: nginx

spec:

replicas: 1

selector:

matchLabels:

app: nginx

template:

metadata:

labels:

app: nginx

spec:

containers:

- name: nginx

image: nginx

imagePullPolicy: IfNotPresent

ports:

- containerPort: 80

— -

apiVersion: v1

kind: Service

metadata:

name: nginx

labels:

app: nginx

spec:

type: NodePort

ports:

- port: 80

nodePort: 30010

selector:

app: nginx

EOF

Deploy nginx web app using below command:

#Kubectl apply -f nginx.yaml

Check app is running on below URL:

http://IP_OF_MACHINE:30010

Some useful commands:

To check docker images:

#crictl images

To check running containers:

#crictl ps

To pull docker images:

#crictl pull IMAG_ENAME

To pull docker images from the private repository:

#crictl pull — creds $registry_username:$registry_pass IMAGE_NAME

Conclusion:

In this blog, we have seen the implementation of containerd in the Kubernetes cluster as we know Kubernetes is deprecating the docker in the upcoming release.

--

--

No responses yet