K8s note with CentOS 8
It's for a long time that I haven't use K8s, and now I realize it's necessary to understand more and practice more about K8s.
Now, We'll try to establish a POC for K8s with CentOS 8 under virsh Env.
Actually, 1st I tried to use Fedora 32 for host to deploy K8s installation. And soon I found there's always error when tried to use kubeadm command to deploy the master/worker nodes. Searching articles about F32 and I realize that F32 use cgroup v2 but K8s' latest version still build under cgroup v1 and that made the deployment failed.
After using CentOS 8 , the issue of deployment failure didn't happpen anymore. In the pre-condition, we need to setup each virtual host to a fixed IP address, whatever using static IP or MAC-bounded IPv4 address is all right. And make sure disable SELinux and firewall daemon.
Then, we need to install docker-CE and the latest K8s version:
After adding all nodes, we could use:
Now, we need to copy some file to our root directory:
Then we could issue the command:
Now, We'll try to establish a POC for K8s with CentOS 8 under virsh Env.
Actually, 1st I tried to use Fedora 32 for host to deploy K8s installation. And soon I found there's always error when tried to use kubeadm command to deploy the master/worker nodes. Searching articles about F32 and I realize that F32 use cgroup v2 but K8s' latest version still build under cgroup v1 and that made the deployment failed.
After using CentOS 8 , the issue of deployment failure didn't happpen anymore. In the pre-condition, we need to setup each virtual host to a fixed IP address, whatever using static IP or MAC-bounded IPv4 address is all right. And make sure disable SELinux and firewall daemon.
Then, we need to install docker-CE and the latest K8s version:
Docker:
# dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo # dnf install https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm --> so far there's no pkg for CentOS8 so that we use previous vertion. # dnf install docker-ce
Enable the Docker:
# systemctl enable docker;systemctl start docker
Instasll kubeadm to the master node:
# cat <BTW, turnoff the SWAP space in every K8s node:/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 # dnf install kubeadm -y # systemctl enable kubelet; systemctl start kubelet
# swapoff -a
Initial the kubeadm:
#kubeadm initIf everything goes well, you should found a command after initialization:
"kubeadm join [IP of master node]:6443 --token nu06lu.xrsux0ss0ixtnms5 –discovery token-ca-cert-hash sha256:f996ea35r4353d342fdea2997a1cf8caeddafd6d4360d606dbc82314683478hjmf7"Please take care that every initialization should get different CA cert, just make sure there should be a command with "kubeadm join" start so that we could use the commands to join new node into the master node.
After adding all nodes, we could use:
# kubectl get nodesThe command help us understand current all nodes' condition.
Now, we need to copy some file to our root directory:
# mkdir -p $HOME/.kube # cp -i /etc/kubernetes/admin.conf $HOME/.kube/config # chown $(id -u):$(id -g) $HOME/.kube/configBefore adding nodes, we need to create a POD network.In the example, I choose flannel network:
# kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.ymlMore detail please refer to here. Then, go to the other nodes that we'd like to add into the cluster and issue the command as above. Please be aware that we have to make sure all nodes knows each other so that we have to establish DNS service or add name records in /etc/hosts for every nodes.
Then we could issue the command:
# kubeadm join [IP of master node]:6443 --token nu06lu.xrsux0ss0ixtnms5 –discovery token-ca-cert-hash sha256:f996ea35r4353d342fdea2997a1cf8caeddafd6d4360d606dbc82314683478hjmf7And then go to the master node to issue get node command to make sure all nodes could be found.