Writing in the front

The detailed process of building a K8S cluster using binary is recorded and shared. Due to the lengthy operation, it will be written in four parts:

  1. The machine to prepare
  2. Deploy the ETCD cluster
  3. The deployment of the Master
  4. The deployment of the Node

The whole goal is to build a small K8S cluster (1 Master, 2 nodes) in binary mode for learning and testing.

Why build K8S in binary mode instead of minikube or Kubeadm?

Because of the use of binary architecture, every component of K8S, every tool needs to be manually installed and configured to help you deepen the understanding of K8S organizational structure and working principle.

The preparatory work

Three centos7 VMS, one core 1G should be enough for learning to use by yourself.

The VIRTUAL machine can be connected to the Internet, and the related installation package files and Docker images must be downloaded from the Internet.

Current VM:

  • K8s – master01:192.168.115.131
  • K8s – node01:192.168.115.132
  • K8s – node02:192.168.115.133

The VM is initialized

Without special instructions:

  • The following operations need to be performed on all machines of the Master and Node

  • Execute commands with sudo permission

Configuring network Interfaces

#If the IP address cannot be obtained using IP addr, run the dhclient command
dhclient 
Copy the code

Installing basic Software

yum install vim ntp wget -y
Copy the code

Change the host name and add hosts

Execute on K8S-Master01

hostnamectl set-hostname "k8s-master01"
Copy the code

Run the command on k8S-node01

hostnamectl set-hostname "k8s-node01"
Copy the code

Run the command on k8S-node02

hostnamectl set-hostname "k8s-node02"
Copy the code

Add the hosts

vim /etc/hosts
Copy the code

Run the uplink command to add the following content to the file:

192.168.115.131K8S-master01 192.168.115.132k8S-node01 192.168.115.133 K8S-node02Copy the code

Disable the firewall, selinux, and swap

systemctl stop firewalld
systemctl disable firewalld

setenforce 0
sed -i 's/enforcing/disabled/' /etc/selinux/config

swapoff -a
vim /etc/fstab
#Edit the etc/fstab file to comment out the line where swap is located
Copy the code

Synchronization time

ntpdate time.windows.com
Copy the code

Master file preparation

Execute on Master machine:

mkdir /root/kubernetes/resources -p
cd/ root/kubernetes/resources wget https://dl.k8s.io/v1.18.3/kubernetes-server-linux-amd64.tar.gz wget https://github.com/etcd-io/etcd/releases/download/v3.4.9/etcd-v3.4.9-linux-amd64.tar.gz wget https://pkg.cfssl.org/R1.2/cfssl_linux-amd64 wget https://pkg.cfssl.org/R1.2/cfssljson_linux-amd64 wget https://pkg.cfssl.org/R1.2/cfssl-certinfo_linux-amd64 wget https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.ymlCopy the code

Node File preparation

Execute on Node machine:

mkdir /root/kubernetes/resources -p
cd/ root/kubernetes/resources wget https://dl.k8s.io/v1.18.3/kubernetes-node-linux-amd64.tar.gz wget https://github.com/etcd-io/etcd/releases/download/v3.4.9/etcd-v3.4.9-linux-amd64.tar.gz wget https://github.com/containernetworking/plugins/releases/download/v0.8.6/cni-plugins-linux-amd64-v0.8.6.tgzCopy the code

Some files are large and may take a long time to download. You can download it in advance and copy it to a VIRTUAL machine.

The first paragraph machine is ready for a happy ending.