Get the App
SLTechnology News&Howtos  ›  Servers  › 

Setting up Kubernetes Cluster under CentOS (1) preset of Host Environment

Shulou Source: shulou.com Published: 2022-06-03 04:17:20 10月16日 Update

Although there are distributions such as Rancher OS and CoreOS, the installation of Kubernetes clusters is not too troublesome, so let's start with the most basic experiments. The following is my CentOS7.6 installation of Kubernetes cluster notes, and chapter-by-chapter records, continuous updates.

Kubernetes host environment preset

There are also many choices for the host production environment of the Kubernete cluster, as follows:

Scheme 1: three or five Master nodes, install full roles respectively: ETCD, Control Plane; other nodes are container computer nodes, install roles respectively: worker; scheme 2: three nodes install roles: ETCD; two nodes install roles: Control Plane; other nodes are container computer nodes, install roles: worker

But now I only have a 7-generation i7 notebook. Although it has 16 GB of memory, this dual-core four-thread is really not good enough. Do not consider stand-alone and minikube installation first, and then implement it one by one after the small experimental cluster has finished the experiment. My notebook is an installed fedora, using the kvm virtual machine to virtualize three hosts each with 1vcpu+1G memory, installing one master node and two compute nodes respectively.

The kubernetes components that each node needs to install are as follows:

Master Node: kube-apiserverkube-controller-managerkube-schedulerkube-proxypauseetcdcoredns Slave Node: kube-proxypauseflannel (the network plug-in selected in this experiment) 1.2 sets time synchronization

For example, chrony, configuration file / etc/chrony.conf (time server needs to be configured in private network), and systemctl command is used to start the service. It is recommended to configure a time synchronization server for the cluster regardless of the private network and the environment that can connect to the Internet.

1.3 configure DNS or hosts host resolution

Configure cluster IP and hostname resolution in the / etc/hosts file (while reducing DNS resolution latency)

1.4 turn off the firewall

Turn off the firewall on CentOS7

# systemctl stop firewalld.service# systemctl disable firewalld.service1.5 closes SELinux# setenforce 0

/ etc/selinux/config file when configured at the same time

# vim / etc/selinux/config...SELINUX=disable

Or

# sed-I's @ ^\ (SELINUX=\). * @\ 1disable swap devices / etc/sysconfig/selinux1.6

Kubernetes 1.8 needs to shut down the system Swap swap partition at first, but it cannot be started if it is not turned off.

View

# free-m

Temporarily Closed

# swapoff-a # echo "vm.swappiness = 0" > > / etc/sysctl.conf

Or

# swapoff-a & & sysctl-w vm.swappiness=0

At the same time, edit the configuration file / etc/fstab to permanently close, that is, comment on the line where the swap device is mounted.

Note: this experiment is not closed due to limited resources, but there are subsequent solutions (only in the experimental environment)

1.7 enable IPVS kernel module

Kube-proxy supports iptables and ipvs. If conditions are met, ipvs is used by default, otherwise iptables is used.

Cat / etc/sysconfig/modules/ipvs.modules 192.168.0.1:6443 Masq 1 1 0

If the above prerequisites are not met, even if ipvs mode is enabled for the configuration of kube-proxy, it will be returned to iptables mode.

Tags: Node configuration host cluster lab kernel file role environment module at the same time time note service memory premise command container scheme server Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft vpn Redmi Shulou Tech Info Huawei