Create Kubernetes 1.21.0 on Ubuntu 18.04

  • Read

These days I created a K8s 1.21.0 cluster on Ubuntu 18.04 to prepare the CKA exam, and found there are some tips which could be shared here.

To make it simple, the cluster is based on CRI-O container runtime and another reason is that CRI-O is also used by RedHat Openshift 4 and I also want to know more about it.

First of first, need to upgrade the kernel to 5.X:

sudo apt-get install --install-recommends linux-generic-hwe-18.04

Almost no one mentioned this point and it took me more than one hour to figure out I had to upgrade the kernel to 5.X to support overlay2 or the container could not be created successfully and the kubeadm would always failed.

Then refer to this page: Install cri-o runtime

cat <<EOF | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
deb$OS/ /
cat <<EOF | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable:cri-o:$VERSION.list
deb$VERSION/$OS/ /

curl -L$OS/Release.key | sudo apt-key --keyring /etc/apt/trusted.gpg.d/libcontainers.gpg add -
curl -L$VERSION/$OS/Release.key | sudo apt-key --keyring /etc/apt/trusted.gpg.d/libcontainers-cri-o.gpg add -

sudo apt-get update
sudo apt-get install cri-o cri-o-runc
sudo systemctl daemon-reload
sudo systemctl enable crio --now

Then continue to install kubeadm, kubectl and kubelet.

sudo apt-get install -y apt-transport-https ca-certificates curl
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubelet=1.21.0-00 kubeadm=1.21.0-00 kubectl=1.21.0-00
sudo apt-mark hold kubelet kubeadm kubectl

Make sure the /etc/hosts files are consistent on all nodes and disable swap.

And below code was used to make sure the kubeadm would use systemd:

# kubeadm-config.yaml
kind: ClusterConfiguration
kubernetesVersion: v1.21.0
kind: KubeletConfiguration
cgroupDriver: systemd
serverTLSBootstrap: true

Then run 'kubeadm init --config kubeadm-config.yaml' as instructed in the Kubernetes document and you will get below error message:

neilzh@k8smaster:~$ sudo kubeadm init --config ./kubeadm-config.yaml
W0806 09:25:36.251646   10406 strict.go:47] unknown configuration schema.GroupVersionKind{Group:"", Version:"v1beta3", Kind:"ClusterConfiguration"} for scheme definitions in "" and ""
no kind "ClusterConfiguration" is registered for version "" in scheme ""
To see the stack trace of this error execute with --v=5 or higher

I searched the error and could not find any answer so I tried to modify the file many times and finally below modification fixed it.

apiVersion:  --> apiVersion:

Then the cluster could be created.

  • by Published on 07/08/2021 04:57:49
  • Repost please keep this link:


Anonymous Write

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: