Docker Method for Deploying Rancher of Pit Free

  • 2021-10-11 20:02:49
  • OfStack

Must see before operation:

Note: If you want to use ranhcer for management, you need to use your k8s cluster before it is set up. If k8s has already set up rancher import cluster function will not be used, you need to start master after master and node, then import curl-insecure-sfL * *, that is, line 3 command. Only after master node is executed can node execute kubeadm join join cluster command
Note: If the host name is not changed before k8s is deployed, do not change it after k8s is deployed. If you change it, your node will be directly NotReady. It is best to change the host name before deployment

Note: If you add master to ranche, you will be prompted as follows:
Warning: Components controller-manager are unhealthy
Warning: Unhealthy component scheduler

You can do the following:

master execution to view cluster status


kubelet get cs

Check that the port is not listening


ss -ant| grep 10251
ss -ant| grep 10252

The pod component is working properly


kubelet get pods --all-namespaces

Check whether the kube-scheduler and kube-controller-manager component configuration disables non-secure ports


vim /etc/kubernetes/manifests/kube-scheduler.yaml
vim /etc/kubernetes/manifests/kube-controller-manager.yaml

If all are normal, use # annotation to restart port=0 in kube-scheduler. yaml and kube-controller-manager. yaml and try again. I annotate that it has returned to normal after restarting. If it is not restored, I need to find other methods


systemctl restart kubelet

Security Group


 Inbound 
TCP:22 80 443 2376 2379 2380 6443 9099 10250-10252 10254 10256 
UDP:4789 8472
30000-32767 TCP/UDP(nodeport)
 Outbound all traffic 

Deploying DOCKER


sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce -y
sudo systemctl enable docker
sudo systemctl start docker

Start rancher


sudo docker run --privileged -d --restart=unless-stopped \
 -p 80:80 -p 443:443 \
 -v /host/rancher:/var/lib/rancher \
 -v /var/log/rancher/auditlog:/var/log/auditlog \
 -e AUDIT_LEVEL=1 \
 rancher/rancher:stable

Related articles: