@ Author:By Runsen
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. .
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
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