Use Rancher to build a K8s cluster under CentOS7

What is Rancher

Rancher is a container management platform, which can help organizations deploy and manage containers in a production environment easily and quickly.

Rancher can easily manage Kubernetes in various environments, meet IT needs and provide support for DevOps teams.

Kubernetes has not only become the container orchestration standard, it is also rapidly becoming a standard infrastructure provided by various cloud and virtualization vendors.

Rancher users can choose to use Rancher Kubernetes Engine (RKE) to create a Kubernetes cluster, or use cloud Kubernetes services such as GKE, AKS, and EKS.

Rancher users can also import and manage existing Kubernetes clusters.

Use rancher to build a k8s cluster in the environment shown below

rancher 10.20.90.46
node1 10.20.90.165
node2 10.20.90.166
node3 10.20.90.166

Specific steps are as follows

1、4 All CentOS7 hosts are installed with docker

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
sed -i -e '/mirrors.cloud.aliyuncs.com/d'-e '/mirrors.aliyuncs.com/d'/etc/yum.repos.d/CentOS-Base.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
yum -y install docker-ce
 
# Configure docker image acceleration
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'{"registry-mirrors":["https://1jk30jsb.mirror.aliyuncs.com"]}
EOF
systemctl daemon-reload
systemctl restart docker
systemctl enable docker.service
docker -v View docker version information

Note that for convenience, SELINUX and Firewalld are turned off on each machine

Write the above steps directly into scripts and execute them directly to improve efficiency

2、 Install rancher on the rancher server

docker run -d --restart=unless-stopped \
 - p 80:80-p 443:443 \
 - - privileged \
 rancher/rancher:latest

Wait about 1 minute for the rancher image to be pulled

docker images
docker ps 

3、 Log in to the rancher management interface to create a rancher-k8s cluster

Switch to Chinese

Add cluster

Custom cluster name, such as rancher-k8s

**Check the role as etcd controlplane worker **

Follow the prompts on the web interface to copy the command and execute it on node1, node2, and node3

docker run -d --privileged --restart=unless-stopped --net=host -v /etc/kubernetes:/etc/kubernetes -v /var/run:/var/run rancher/rancher-agent:v2.5.1--server https://10.20.90.46--token wlvv9z4kwz2bxkcfffmptdsc75hfk7xncwgc552dsz6vhp4gfzsq7w --ca-checksum 57dc6fb5cab3d0eafd0a9cd5a44e67254264a53c9da08ea456dd45d291f33843 --etcd --controlplane --worker

4、 Waiting for the successful establishment of the cluster

5、 Create workload

For example, create nginx service

Recommended Posts

Use Rancher to build a K8s cluster under CentOS7
Build a PXC cluster under CentOS8
(1) Centos7 installation to build a cluster environment
Build a ScaleIO distributed storage cluster under CentOS7
First try to build a Ceph storage cluster on Centos7
[PHP] Build a PHP operating environment under CentOS
How to quickly build Nginx server under CentOS
Centos7 tutorial to build a master-slave DNS server
How to build a LAMP environment on centos7.2
Build k8s1.9.9 on centos7
CentOS7.3.1611 deploys k8s1.5.2 cluster
Centos6.9 build rabbitmq 3.6.8 cluster
Centos7 build Kubernetes cluster
CentOS7 deploys k8s cluster
Build a basic environment for Java development under Centos7
CentOS uses Nginx to build a download function server
Centos8 implementation steps to build a local web server
Build docker environment under Centos6.5
Build OpenV** Server under CentOS7
Build OpenLDAP server under CentOS7
Redis cluster installation under CentOS
Redis cluster installation under CentOS
CentOs7.3 build SolrCloud cluster service
Centos7 install k8s cluster 1.15.0 version
Use Jexus 5.8.2 to deploy and run Asp.net core under Centos
Detailed steps to install and configure k8s cluster in centos 7
How to establish a multi-node Elastic stack cluster on RHEL8 /CentOS8
[Introduction to redis] Install redis under Centos
RabbitMQ cluster deployment record under Centos6.9
Elasticsearch cluster deployment record under CentOS7
Centos6 method steps to build gitlab
Build an FTP server under centos7
Install and use docker under CentOS 6.8
Use VMware15 to install Linux (CentOS6.5)
k8s practice (1): Centos 7.6 deployment k8s (v1.14.2) cluster
A brief introduction to yum source configuration and nmcli commands under CentOS8
Centos7 uses vim to build powerful pyt
Installation and use of Mysql under CentOS
Use mendeley to insert references under ubuntu
Centos7 deploys HAproxy to implement Nginx cluster
Use supermin to make CentOS Docker image
KVM installation and preliminary use under CentOS 7.2
Build a python development environment under Ubuntu
Three ways to install JDK under CentOS
Centos8 use yum to install rabbitmq tutorial
Build a highly available Replication cluster to archive large amounts of cold data
CentOS Discovery Road 2---Use rpm to install JDK
How to install and use Docker on CentOS 7
Summary of methods to use Evernote under Ubuntu 14.04
Use rsync to remotely backup data under Ubuntu
K8S: (1) A preliminary study on CentOS stand-alone deployment
Python3 development environment to build a detailed tutorial
Build Discuz Forum in LNMP Environment under CentOS7
Use doxygen to generate API documentation under Ubuntu 12.04
How to install and use Composer on CentOS 8
Build LEMP (Linux+Nginx+MySQL+PHP) environment under CentOS 8.1 (detailed tutorial)
How to quickly modify root password under CentOS8
How to use Jenkins to build automatically on Ubuntu
Build Dedecms website in LNMP environment under CentOS7
Add a new project to SVN under Ubuntu
How to install and use Curl on CentOS 8