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 <
[ 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
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown
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