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
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
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
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
For example, create nginx service
Recommended Posts