Centos7 build Kubernetes cluster

@ Author:By Runsen

Kubernetes

Kubernetes and its entire ecosystem (tools, modules, plug-ins, etc.) are written in the Go language to form a set of API-oriented, high-speed running programs. These programs are well-documented and easy to contribute to or build applications on top of them. (Baidu Encyclopedia)

So what is the use of Kubernetes? It's actually very simple. Docker is the container for deploying our project, but one container is not enough to deploy. If you use Docker to create containers in multiple Linux servers, you need to manage the containers of multiple Linux servers. Kubernetes manages Docker containers. .

Build a Kubernetes cluster

Then we formally build a Kubernetes cluster. What is a cluster is multiple Linux servers. In fact, it is similar to Hadoop, elasticsearch, and CDH clusters. The configuration of CDH is simpler than Hadoop.

The machine I chose was three centos7 hosts, and there was no money to buy a server. Before configuring three servers with sh password-free login and Docker, I will not introduce them one by one here.

NodeName IP address
node01 192.168.92.90
node02 192.168.92.91
node03 192.168.92.92

Before setting up, visit the Chinese document http://docs.kubernetes.org.cn/ and the English document https://kubernetes.io/docs

The first step is to configure the source, load and download speed, Installing kubeadm, you can yum install, the following figure is the installation command of the official document

I’ll just use vim to create it directly. Google doesn’t seem to work well, but Ali’s

[ root@node01 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1   localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.92.90 node01
192.168.92.91 node02
192.168.92.92 node03
[ root@node01 ~]# vim /etc/yum.repos.d/kubernetes.repo
#########
[ kubernetes]
name=Kubernetes
baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg http://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
[ root@node01 ~]# yum install -y kubelet kubeadm kubectl
Loaded plugin: fastestmirror
……………………
Installed:
 ubeadm.x86_64 0:1.18.2-0   kubectl.x86_64 0:1.18.2-0   kubelet.x86_64 0:1.18.2-0
Installed as a dependency:
 conntrack-tools.x86_64 0:1.4.4-5.el7_7.2
 cri-tools.x86_64 0:1.13.0-0
 kubernetes-cni.x86_64 0:0.7.5-0
 libnetfilter_cthelper.x86_64 0:1.0.0-10.el7_7.1
 libnetfilter_cttimeout.x86_64 0:1.0.0-6.el7_7.1
 libnetfilter_queue.x86_64 0:1.0.2-2.el7_2
 socat.x86_64 0:1.7.3.2-2.el7
complete!
[ root@node01 ~]# systemctl enable docker && systemctl start docker
[ root@node01 ~]# systemctl enable kubelet && systemctl start kubelet
[ root@node01 ~]# kubeadm
 ┌──────────────────────────────────────────────────────────┐
 │ KUBEADM                                                  │
 │ Easily bootstrap a secure Kubernetes cluster             │
 │                                                          │
 │ Please give us feedback at:                              │
 │ https://github.com/kubernetes/kubeadm/issues             │
 └──────────────────────────────────────────────────────────┘

Next is the Kubernetes deployed by kubeadm for us. Here is the latest 1.18.2, you can leave it alone

[ root@node01 ~]# kubeadm init --apiserver-advertise-address=192.168.92.90--image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.18.2--service-cidr=10.1.0.0/16--pod-network-cidr=10.244.0.0/16

Found the report [ERROR Swap]: running with swap on is not supported. Please disable swap

Then disable swap and execute the above command again

[ root@node01 ~]# systemctl stop firewalld
[ root@node01 ~]# swapoff -a
[ root@node01 ~]# kubeadm init --apiserver-advertise-address=192.168.92.90--image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.18.2--service-cidr=10.1.0.0/16--pod-network-cidr=10.244.0.0/16

When you see kubeadm join 192.168.92.90:6443 --token niim2r.u8sgcz1vybxtfs68, the installation is successful.

Ask us to run the following command during output, which should create environment variables.

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

After Kubernetes is installed, you can view the generated directory in /etc/kubernetes/

[ root@node01 ~]# ls /etc/kubernetes/
admin.conf  controller-manager.conf  kubelet.conf  manifests  pki  scheduler.conf

The kubectl get nodes command can view the current nodes.

[ root@node01 ~]# kubectl get nodes
NAME     STATUS     ROLES    AGE     VERSION
node01   NotReady   master   4m12s   v1.18.2

Configure the cluster

Now repeat the above operations on node02 and node03

[ root@node02 ~]# kubeadm init --apiserver-advertise-address=192.168.92.91--image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.18.2--service-cidr=10.1.0.0/16--pod-network-cidr=10.244.0.0/16[root@node03 ~]# kubeadm init --apiserver-advertise-address=192.168.92.92--image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.18.2--service-cidr=10.1.0.0/16--pod-network-cidr=10.244.0.0/16[root@node01 ~]# kubectl get nodes
NAME     STATUS     ROLES    AGE     VERSION
node01   NotReady   master   4m12s   v1.18.2
node02   NotReady   <none>   4m12s   v1.18.2
node03   NotReady   <none>   4m12s   v1.18.2

The above information appears and the cluster configuration is successful.

Recommended Posts

Centos7 build Kubernetes cluster
Centos6.9 build rabbitmq 3.6.8 cluster
Centos7 deploys Kubernetes cluster
Centos7.2/7.3 cluster install Kubernetes 1.8.4 + Dashboard
CentOs7.3 build SolrCloud cluster service
Build a PXC cluster under CentOS8
CentOS7 build jenkins
Centos build lnmp
Centos7 build python3.8.5+scrapy+gerapy
CentOS7 install Kubernetes 1.16.3
(1) Centos7 installation to build a cluster environment
CentOS7.3 64 bit, build Zabbix3.4
CentOS build private git
Linux (centos7) build gitlab
Build k8s1.9.9 on centos7
Build a ScaleIO distributed storage cluster under CentOS7
CentOS6.7 build LNMP environment
CentOS7.3.1611 deploys k8s1.5.2 cluster
CentOS6 install couchdb2 cluster
CentOS 6.8 deploy zookeeper cluster
Centos7 install kubernetes tutorial
Centos7 mqtt cluster installation
Jenkins build on centos
Build Hadoop in CentOS
CentOS cluster related issues
Centos7 build DNS service
CentOS7 deploys k8s cluster
CentOS 7 build LNMP environment
Use Rancher to build a K8s cluster under CentOS7
Rapid deployment of Kubernetes (k8s) cluster in CentOS7 environment
Build docker environment under Centos6.5
CentOs7.3 build Solr stand-alone service
Build OpenV** Server under CentOS7
Build zabbix monitoring zabbix4.2 in CentOS7.6
Centos7.4 deployment configuration Elasticsearch5.6 cluster
Build OpenLDAP server under CentOS7
CentOS7 install rabbitmq cluster (binary)
Redis cluster installation under CentOS
Build zabbix monitoring zabbix4.2 in CentOS7.6
CentOS 7 Galera Cluster installation guide
Build MariaDB replication on CentOS
CentOs7.3 build ZooKeeper-3.4.9 stand-alone service
Redis cluster installation under CentOS
Centos7 install k8s cluster 1.15.0 version
First try to build a Ceph storage cluster on Centos7
CentOS 8 (2)
CentOS8.1 build Gitlab server detailed tutorial
Centos7 hadoop cluster installation and configuration
Elasticsearch cluster deployment record under CentOS7
Centos6 method steps to build gitlab
Build an FTP server under centos7
CentOS 8 (1)
Build Elasticsearch 6.2.4 (centos) based on docker
Build Nginx environment on Linux (CentOS)
(centos7) linux build nginx load balancing build
Centos7 build java web server tomcat
Build Discuz Forum based on CentOS
Build Yum private warehouse in Centos7.3
k8s practice (1): Centos 7.6 deployment k8s (v1.14.2) cluster
virtualBox install centos, and build tomcat
Build WeChat applet service based on CentOS