Feynman
Published on:2021-09-29    The number of views:

Install Kubernetes 1.22 and containerd the Easy Way

k8s-containerd

KubeKey is a lightweight and turn-key installer that supports the installation of Kubernetes, KubeSphere and related add-ons. Writtent in Go, KubeKey enables you to set up a Kubernetes cluster within minutes. In this blog, we will install Kubernetes 1.22 and containerd in one command with KubeKey.

Step 1: Prepare a Linux Machine

To get started with all-in-one installation, you only need to prepare one host according to the following requirements for hardware and operating system.

Hardware Recommendations

OS Minimum Requirements
Ubuntu 16.04, 18.04 2 CPU cores, 2 GB memory, and 40 GB disk space
Debian Buster, Stretch 2 CPU cores, 2 GB memory, and 40 GB disk space
CentOS 7.x 2 CPU cores, 2 GB memory, and 40 GB disk space
Red Hat Enterprise Linux 7 2 CPU cores, 2 GB memory, and 40 GB disk space
SUSE Linux Enterprise Server 15/openSUSE Leap 15.2 2 CPU cores, 2 GB memory, and 40 GB disk space

Node requirements

  • The node can be accessed through SSH.
  • sudo/curl/openssl should be used.

Dependency requirements

KubeKey can install Kubernetes and KubeSphere together. The dependency that needs to be installed may be different based on the Kubernetes version to be installed. You can refer to the following list to see if you need to install relevant dependencies on your node in advance.

Dependency Kubernetes Version ≥ 1.18 Kubernetes Version < 1.18
socat Required Optional but recommended
conntrack Required Optional but recommended
ebtables Optional but recommended Optional but recommended
ipset Optional but recommended Optional but recommended

Network and DNS requirements

  • Make sure the DNS address in /etc/resolv.conf is available. Otherwise, it may cause some issues of DNS in the cluster.
  • If your network configuration uses firewall rules or security groups, you must ensure infrastructure components can communicate with each other through specific ports. It is recommended that you turn off the firewall. For more information, see Port Requirements.
  • Supported CNI plugins: Calico and Flannel. Others (such as Cilium and Kube-OVN) may also work but note that they have not been fully tested.

Step 2: Download KubeKey

Perform the following steps to download KubeKey.

Download KubeKey from its GitHub Release Page or run the following command:

curl -L https://github.com/kubesphere/kubekey/releases/download/v1.2.0-alpha.4/kubekey-v1.2.0-alpha.4-linux-amd64.tar.gz > installer.tar.gz && tar -zxf installer.tar.gz

Run the following command first to make sure you download KubeKey from the correct zone.

export KKZONE=cn

Run the following command to download KubeKey:

curl -L https://github.com/kubesphere/kubekey/releases/download/v1.2.0-alpha.4/kubekey-v1.2.0-alpha.4-linux-amd64.tar.gz > installer.tar.gz && tar -zxf installer.tar.gz

Note

After you download KubeKey, if you transfer it to a new machine also with poor network connections to Googleapis, you must run export KKZONE=cn again before you proceed with the following steps.

Make kk executable:

chmod +x kk

Step 3: Get Started with Installation

You only need to run one command for all-in-one installation.

./kk create cluster --with-kubernetes v1.22.1 --container-manager containerd 

Note

  • Supported Kubernetes versions: v1.19.8, v1.20.4, v1.21.4, v1.22.1. If you do not specify a Kubernetes version, KubeKey installs Kubernetes v1.21.5 by default. For more information about supported Kubernetes versions, see Support Matrix.
  • For all-in-one installation, you do not need to change any configuration.
  • KubeKey supports AMD64 and ARM64.

After you run the command, you will see a table for environment check. For details, see Node requirements and Dependency requirements. Type yes to continue.

Step 4: Verify the Installation

If the following information is displayed, Kubernetes is successfully installed.

INFO[00:40:00 CST] Congratulations! Installation is successful.

Run the following command to check the container runtime and Kubernetes version.

kubectl get node -o wide
NAME         STATUS   ROLES                         AGE   VERSION   INTERNAL-IP   EXTERNAL-IP   OS-IMAGE                KERNEL-VERSION           CONTAINER-RUNTIME
i-mxtuejcj   Ready    control-plane,master,worker   45s   v1.22.1   192.168.6.2   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   containerd://1.4.9

Run the following command to check the Pod status.

kubectl get pod --all-namespaces
NAMESPACE     NAME                                       READY   STATUS    RESTARTS   AGE
kube-system   calico-kube-controllers-75ddb95444-6vgcm   1/1     Running   0          39s
kube-system   calico-node-knhhs                          1/1     Running   0          39s
kube-system   coredns-5495dd7c88-6w5gt                   1/1     Running   0          48s
kube-system   coredns-5495dd7c88-982kj                   1/1     Running   0          48s
kube-system   kube-apiserver-i-mxtuejcj                  1/1     Running   0          56s
kube-system   kube-controller-manager-i-mxtuejcj         1/1     Running   0          56s
kube-system   kube-proxy-6vlsj                           1/1     Running   0          48s
kube-system   kube-scheduler-i-mxtuejcj                  1/1     Running   0          64s
kube-system   nodelocaldns-7zqp2                         1/1     Running   0          48s

Congratulations! You have installed a sing-node Kubernetes cluster with containerd. For advanced usage of KubeKey, see Installing on Linux — Overview for more information.

close

Receive the latest news, articles and updates from KubeSphere