Kubernetes Installation with containerd

GT Aswin
3 min readJun 19, 2018

Cri-containerd is an implementation of CRI for containerd. It operates on the same node as the Kubelet and containerd. Layered between Kubernetes and containerd, cri-containerd handles all CRI service requests from the Kubelet and uses containerd to manage containers and container images. Because of containerd you can get better performance in kubernetes cluster compare to docker.

On Every nodes

Run the given commands on every nodes(both master and slave). I provide the simple script for both Centos and Debian distros.

For Centos7

#Run it as root user
export CONTAINERD_VERSION=1.1.0
yum install wget -y
wget https://storage.googleapis.com/cri-containerd-release/cri-containerd-${CONTAINERD_VERSION}.linux-amd64.tar.gz
tar xzf cri-containerd-${CONTAINERD_VERSION}.linux-amd64.tar.gz -C /
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF
systemctl disable firewalld && systemctl stop firewalld
setenforce 0
echo "SELINUX=disabled" > /etc/sysconfig/selinux
swapoff -a
sed -e '/swap/ s/^#*/#/' -i /etc/fstab
cat <<EOF >> /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system
yum install -y kubelet kubeadm kubectl
cat <<EOF > /etc/systemd/system/kubelet.service.d/0-containerd.conf
[Service]
Environment="KUBELET_EXTRA_ARGS=--container-runtime=remote --runtime-request-timeout=15m --container-runtime-endpoint=unix:///run/containerd/containerd.sock"
EOF
kubeadm reset
systemctl daemon-reload
systemctl enable containerd && systemctl start containerd
systemctl enable kubelet && systemctl start kubelet

For Ubuntu/Debian

#Run it as root user
#Enter the version of containerd
export CONTAINERD_VERSION=1.1.0
#Enter the OS Distribution #Here i'm using xenial
#you can also use stretch, trusty etc..
export OS_DISTRIBUTION=xenial
wget https://storage.googleapis.com/cri-containerd-release/cri-containerd-${CONTAINERD_VERSION}.linux-amd64.tar.gz
tar xzf cri-containerd-${CONTAINERD_VERSION}.linux-amd64.tar.gz -C /
apt-get update && apt-get install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-${OS_DISTRIBUTION} main
EOF
swapoff -a
sed -e '/swap/ s/^#*/#/' -i /etc/fstab
cat <<EOF >> /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system
apt-get update
apt-get install -y kubelet kubeadm kubectl
cat <<EOF > /etc/systemd/system/kubelet.service.d/0-containerd.conf
[Service]
Environment="KUBELET_EXTRA_ARGS=--container-runtime=remote --runtime-request-timeout=15m --container-runtime-endpoint=unix:///run/containerd/containerd.sock"
EOF
kubeadm reset
systemctl daemon-reload
systemctl enable containerd && systemctl start containerd
systemctl enable kubelet && systemctl start kubelet

On Master Node

For all Distribution(Centos/Debian/Ubuntu) run this kubeadm commands to starting the master node.

sudo kubeadm init --skip-preflight-checks --apiserver-advertise-address 10.0.0.XXX
rm -rf $HOME/.kube
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"

On Slave Node

In slave nodes run this kubeadm command to join with generated token from master node.

kubeadm join 10.0.0.XXX:6443 --token XXXX --skip-preflight-checks

Hope this is helpful. Now you can able to setup kubernetes cluster with containerd instead of docker.

--

--