Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install a Kubernetes cluster on CentOS

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the knowledge of "how to install Kubernetes clusters on CentOS". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1.Kubernetes host environment preset

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

Solution 1: three or five Master nodes are installed with full roles: ETCD and Control Plane respectively; other nodes are container computer nodes, and roles are installed respectively: worker

Solution 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:

Primary node:

Kube-apiserver

Kube-controller-manager

Kube-scheduler

Kube-proxy

Pause

Etcd

Coredns

Slave node:

Kube-proxy

Pause

Flannel (the network plug-in selected in this lab)

1.2 set 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.

two。 Install the package

Use docker as a container to run

2.1 configure to run some system tools necessary for Docker2.1.1 installation # yum install-y yum-utils device-mapper-persistent-data lvm22.1.2 add docker source # yum-config-manager-add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

You can use the domestic image acceleration service. Refer to the official documentation of kubernetes, where the installation of Ali's image on CentOS is used as an explanation. (when taking this note, I tried the kubernetes of Huawei, Tencent and Tencent as well as the University of Electronic Science and Technology. It seems that the version of Ali is not as new as Ali's, so I will try Ali's for the time being).

2.1.3 Update and install Docker-CE# yum makecache fast# yum-y install docker-ce

The latest stable version is installed here according to the default configuration of the docker source file, but it is likely to fail the latest kubernetes authentication. Therefore, we use the following ways to select the installation version, especially in the reproduction environment.

The first is to find the version in the repository:

# yum list docker-ce.x86_64-- showduplicates | sort-rLoading mirror speeds from cached hostfileLoaded plugins: branch, fastestmirror Langpacks...dockdr-ce.x86_64 18.09.9.ce-1.el7.centos docker-ce-stable...docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stabledocker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stableAvailable Packages

Then install the specified version of Docker-CE: (VERSION such as 18.09.9.ce.1-1.el7.centos above)

# yum-y install docker-ce-18.09.9 docker-ce-cli-18.09.92.2 configuration running Docker (offline environment)

Which ISO of Everthing can be used to install dependent libraries if it is an offline installation, but the version of docker installed is older, but it is not a big problem. Of course, you can also package and download the required rpm on a networked host, and then copy it to an offline environment for installation. The key process is as follows:

2.2.1 download the offline package # yum install docker-ce-18.09.9 docker-ce-cli-19.09.9-- downloadonly-- downloaddir=/home//2.2.2 using the yum command and install it in an offline environment (installed in the following order)

1) install the basic dependency package

# rpm-ivh checkpolicy-2.5-8.el7.x86_64.rpm# rpm-ivh libcgroup-0.41-20.el7.x86_64.rpm# rpm-ivh libseccomp-2.3.1-3.el7.x86_64.rpm# rpm-ivh libsemanage-python-2.5-14.el7.x86_64.rpm# rpm-ivh audit-libs-python-2.8.4-4.el7.x86_64.rpm# rpm-ivh setools-libs-3.3.8-4 .el7.x86 _ 64.rpm# rpm-ivh python-IPy-0.75-6.el7.noarch.rpm# rpm-ivh policycoreutils-python-2.5-29.el7.x86_64.rpm

2) install the software package of docker-ce

# rpm-ivh container-selinux-2.99-1.el7_6.noarch.rpm# rpm-ivh containerd.io-1.2.6-3.3.el7.x86_64.rpm# rpm-ivh docker-ce-cli-18.09.7-3.el7.x86_64.rpm# rpm-ivh docker-ce-18.09.7-3.el7.x86_64.rpm

Description:

1. The version of the software package installed above may be different, and there is no need to struggle with it according to the actual situation at the time of installation.

two。 In the case of mounting the ISO of Eerything as the software source, you can directly use the yum command to install the software packages copied to the local container-selinux, containerd.io, docker-ce-cli, docker-ce in the above order.

3. If the above package is in a folder, you can simply use "yum install / * .rpm" to install it.\ "your_path\" is the way to store the above package.

2.3 Docker other Settings 2.3.1 create directory / etc/docker# mkdir / etc/docker2.3.2 create daemon# cat > / etc/docker/daemon.json

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report