Rapid deployment of Kubernetes (k8s) cluster in CentOS7 environment

Kubernetes is an open source, used to manage containerized applications on multiple hosts in the cloud platform. The goal of Kubernetes is to make the deployment of containerized applications simple and efficient. Kubernetes provides application deployment, planning, updating, and maintenance. mechanism

The concept of k8s can refer to the following link

[ The kubernetes tutorial that children can understand](http://mp.weixin.qq.com/s?__biz=MzAwNzY4OTgyNA==&mid=2651826597&idx=1&sn=d9b606b92efe85ad79484deb098b89c7&chksm=80814aaab7f6c3bc39cfenescene&chksm=80814aaab7f6c347239cc391896743472c39216

[ Graphic | A Kubernetes tutorial that anyone can understand! ](http://mp.weixin.qq.com/s?__biz=MzI1OTY2MzMxOQ==&mid=2247487479&idx=1&sn=e5e59c175ec74e993cdf86ef24285c1d&chksm=ea743b4fdd03b25975b808f1acdd2582c9463589scenebenefet_f1acdd2582c9463d

[ Photo: Kubernetes that your girlfriend can understand! ](http://mp.weixin.qq.com/s?__biz=MzI1OTY2MzMxOQ==&mid=2247487526&idx=1&sn=970c7d5e729c2423dd265105e2eb5122&chksm=ea74249edd03ad88a1bc8ceea319981b09091e980becc403557e

The following describes the rapid deployment of a Kubernetes (k8s) cluster in the CentOS7 environment

The memory size of the three CentOS 7.6.1810 Linux virtual machines is 4GB

1、 k8s-master 10.20.10.235

2、 k8s-node1 10.20.10.237

3、 k8s-node2 10.20.10.238

The specific steps are as follows

1、 Environmental preparation

1 ) Modify the host names of the three hosts separately

k8s-master 10.20.10.235: hostnamectl set-hostname k8s-master

k8s-node1 10.20.10.237:hostnamectl set-hostname k8s-node1

k8s-node2 10.20.10.238:hostnamectl set-hostname k8s-node2

All three modified the vi /etc/hosts file and added host name resolution

10.20.10.235 k8s-master

10.20.10.237 k8s-node1

10.20.10.238 k8s-node2

Take node1 as an example, and test whether the analysis is OK

2 ) All three hosts close the firewall, selinux, and close the swap partition

swapoff -a

And permanently close, comment out the swap partition line in /etc/fstab

systemctl stop firewalld

systemctl disable firewalld

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

setenforce 0

echo "net.bridge.bridge-nf-call-iptables = 1 ">>/etc/sysctl.d/k8s.conf

echo "net.bridge.bridge-nf-call-ip6tables = 1 ">>/etc/sysctl.d/k8s.conf

sysctl --system

Turn on net.bridge.bridge-nf-call-iptables=1, which means that the second layer bridge will also be filtered by the FORWARD rule of iptables when forwarding packets

The specific principle can refer to the following article

https://blog.csdn.net/qq_44910432/article/details/89292974

2、 Install docker on all nodes and enable docker

wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo

yum install docker-ce

systemctl enable docker

systemctl start docker

docker version

3、 All nodes are installed and enabled kubelet kubeadm kubectl

cat < /etc/yum.repos.d/kubernetes.repo

[ kubernetes]

name=Kubernetes

baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/

enabled=1

gpgcheck=1

repo_gpgcheck=1

gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg

EOF

yum install -y kubelet kubeadm kubectl

systemctl enable kubelet

systemctl start kubelet

4、 The master node initializes kubeadm init

  1. kubeadm init --image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.17.0 --apiserver-advertise-address 10.20.10.235 --pod-network-cidr=10.244.0.0/16 --service-cidr=10.1.0.0/16

  1. Follow the prompts in the previous step as follows

mkdir -p $HOME/.kube

sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

sudo chown (id -u):(id -g) $HOME/.kube/config

This is whether kubectl get nodes can see that the master is still in NotReady state

5、 Install network flannel components

wget https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

kubectl apply -f kube-flannel.yml

kubectl get pods -n kube-system

kubectl get nodes

Now you can see that the status is Ready

6、 k8s-node1 and k8s-node2 join the cluster

kubeadm join 10.20.10.235:6443 --token h5oegb.ops4pu6ynhmixhwh \

( Token is the prompt when the master node initializes kubeadm init) to join the cluster

At this time, wait for a while and then check the node status to see that the cluster is successfully established

kubectl get pods,svc -n kube-system

7、 Of course, you can also install UI tools such as kubernetes-dashboard to manage the cluster

Next, use the method of installing cockpit to view the kubernetes cluster

For the installation of cockpit, please refer to the previous article Use Cockpit to create KVM virtual machine in CentOS7 environment

yum install cockpit

yum install cockpit-docker.x86_64

yum install cockpit-kubernetes.x86_64

systemctl enable cockpit.socket

systemctl start cockpit.socket

Recommended Posts

Rapid deployment of Kubernetes (k8s) cluster in CentOS7 environment
k8s practice (1): Centos 7.6 deployment k8s (v1.14.2) cluster
Centos-6.5 installation and deployment of LNMP environment
Python and scrapy deployment in centos environment
Simple practice of RHCS cluster in CentOS6
CentOS7.3.1611 deploys k8s1.5.2 cluster
Centos7 build Kubernetes cluster
Centos7 deploys Kubernetes cluster
CentOS7 deploys k8s cluster
[CentOS environment deployment] Java7/Java8 deployment under CentOS
Centos7.4 deployment configuration Elasticsearch5.6 cluster
Centos7.2/7.3 cluster install Kubernetes 1.8.4 + Dashboard
CentOS environment installation of Docker
Centos7 install k8s cluster 1.15.0 version
Ceph rapid deployment (Centos7 + Jewel)
The problem of MySQL import file failure in CentOS environment
Detailed steps to install and configure k8s cluster in centos 7
Centos6.5 installation and deployment of KVM
RabbitMQ cluster deployment record under Centos6.9
Detailed use of nmcli in CentOS8
Binary installation of k8s cluster (1)-opening
FFmpeg environment deployment record under centos7
PPTP environment deployment record under Centos
Tomcat configuration JMX in centos 6.5 environment
Concise summary of Ceph deployment on Centos7
Centos7 installation and deployment of gitlab server
Installation and deployment of Nginx in Ubuntu
(1) Centos7 installation to build a cluster environment
Centos7 installation and deployment of Airflow detailed
Some Centos Python production environment deployment commands
Installation and configuration of JDK in CentOS 7 system
Production environment deployment of ubuntu Django + Uwsgi + Nginx
Deploy Hadoop cluster services in actual CentOS system
Build Discuz Forum in LNMP Environment under CentOS7
LVM disk expansion problem of Centos7 in Linux
Build Dedecms website in LNMP environment under CentOS7
Installation and configuration of CentOS 7 in VMware Workstation
Distributed deployment of Apollo configuration center under CentOS8
Installation and use of SSH in Ubuntu environment