Deploy/Install Rancher 2.7+ in HA with RKE1
- To deploy rancher in HA mode required three machine (Cluster Node Machine) with one deployment machine (i.e. Four Machines Required)
a. Kubectl and RKE1 should install on Deployment machine.
b. From Deployment node to cluster node should be passwordless
c. Docker should install (apt install docker.io -y or yum install docker -y
) on each machine and user should have part of docker group (usermod aG docker <logged-in user>
)
2. Go to following link and choose for which latest stable version is available
https://github.com/rancher/rancher/releases
3. Create private registry to push required images into this registry server.
https://medium.com/@vineetcic/create-your-own-docker-registry-without-gui-simplest-way-25d66c47b94c
OR
https://medium.com/@ifeanyiigili/how-to-setup-a-private-docker-registry-with-a-self-sign-certificate-43a7407a1613
And download required images name and list from below link under assets link after choosing specific rancher version which you want to install (rancher-images.txt, rancher-save-images.txt and rancher-load-images.txt)
https://github.com/rancher/rancher/releases
4. Create a file in Deployment node
Example: rancher-cluster.yaml
private_registries:
- url: registry.name
user: user
password: password
is_default: true
nodes:
- address: 192.168.3.1 #Node1
user: user-name
role: [controlplane,worker,etcd]
- address: 192.168.3.2
user: user-name
role: [controlplane,worker,etcd]
- address: 192.168.3.3
user: user-name
role: [controlplane,worker,etcd]
services:
etcd:
snapshot: true
5. Run rke command where above rancher-cluster.yaml should present
rke up --config ./rancher-cluster.yaml
after completion of above command kubeconfig will present in below location$(pwd)/kube_config_cluster.yml
so use it by default (used in same machine or any machine which has access ) by export commandexport KUBECONFIG=$(pwd)/kube_config_cluster.yml
6. Check Health Of Cluster kubectl get pods — all-namespaces
kubectl get nodes
7. Create namespace and secret for rancher
To install the cluster run the following command
kubectl create namespace cattle-system # Create namespace
kubectl -n cattle-system create secret tls tls-rancher-ingress --cert=tls.crt --key=tls.key
(tls.crt will be full chain)
8. Install Rancher
helm repo add rancher-stable https://releases.rancher.com/server-charts/stable
helm fetch rancher-stable/rancher --version=v2.7.4 # create the tar.gz file
Copy tar file in deployment node or in which machine where want to install rancher
unzip rancher-2.7.4.tgz
cd rancher
export KUBECONFIG=$(pwd)/kube_config_cluster.yml
helm install rancher rancher --namespace cattle-system --set hostname=rancher.portal.domainname --set rancherImage=registry.name/rancher/rancher --set ingress.tls.source=tls-rancher-ingress --set systemDefaultRegistry=registry.name --set useBundledSystemChart=true
9. Now setup proxy to access Rancher Portal
create nginx.conf file with following content
worker_processes 2;
worker_rlimit_nofile 40000;
events {
worker_connections 8192;
}
stream {
upstream rancher_servers_http {
least_conn;
server 192.168.3.3:80 max_fails=3 fail_timeout=5s;
server 192.168.3.2:80 max_fails=3 fail_timeout=5s;
server 192.168.3.1:80 max_fails=3 fail_timeout=5s;
}
server {
listen 80;
proxy_pass rancher_servers_http;
}
upstream rancher_servers_https {
least_conn;
server 192.168.3.1:443 max_fails=3 fail_timeout=5s;
server 192.168.3.2:443 max_fails=3 fail_timeout=5s;
server 192.168.3.3:443 max_fails=3 fail_timeout=5s;
}
server {
listen 443;
proxy_pass rancher_servers_https;
}
}
now run the nginx container using following commands
docker run -d --restart=unless-stopped --name nginx -p 80:80 -p 443:443 -v /etc/nginx/nginx.conf:/etc/nginx/nginx.conf registry.name/rancher/nginx:1.17.4-alpine
10. Open browser with following URL
https://rancher.portal.domainname
11 Enjoy!!!