How to Install Rancher V.2 HA

bayu nugraha
2 min readOct 8, 2020

Make sure your pc has kubectl and rke installed, if not yet install, please refer to this links,

https://kubernetes.io/docs/tasks/tools/install-kubectl/

https://rancher.com/docs/rke/latest/en/installation/

##1##Ssh to 3 nodes , 192.168.0.224, 192.168.0.225, 192.168.0.226

Update vm, sudo apt update –y && sudo apt upgrade –y

Install docker, curl https://releases.rancher.com/install-docker/18.09.sh | sh

add user for user to access docker without root privilege, sudo usermod -aG docker devops

add id_rsa.pub to 3 nodes, ssh-copy-id devops@192.168.0.224, ssh-copy-id devops@192.168.0.225, ssh-copy-id devops@192.168.0.226

add config, vi rancher-knowledge-sharing.yaml

nodes:

- address: 192.168.0.224

internal_address: 192.168.0.224

user: devops

role: [controlplane, worker, etcd]

- address: 192.168.0.225

internal_address: 192.168.0.225

user: devops

role: [controlplane, worker, etcd]

- address: 192.168.0.226

internal_address: 192.168.0.226

user: devops

role: [controlplane, worker, etcd]

services:

etcd:

snapshot: true

creation: 6h

retention: 24h

# Required for external TLS termination with

# ingress-nginx v0.22+

ingress:

provider: nginx

options:

use-forwarded-headers: “true”

Run config earlier, rke up –config rancher-knowledge-sharing.yaml

If failed when running rke up, please repeat rke up 1 more

Move kubeconfig for test cluster, export KUBECONFIG=$(pwd)/kube_config_rancher-knowledge-sharing.yaml

Run kubectl get nodes

Create namespace, kubectl create namespace cattle-system

Deploy cert manager, kubectl apply -f https://raw.githubusercontent.com/jetstack/cert-manager/release-0.12/deploy/manifests/00-crds.yaml

Create namespace for cert-manager, kubectl create namespace cert-manager

Add helm repo and update, helm repo add jetstack https://charts.jetstack.io

Update helm repo, helm repo update

Install jetstack cert-manager, helm install cert-manager jetstack/cert-manager — namespace cert-manager — version v0.12.0

Helm ls –n cert-manager for check helm install in namespace cert-manager

Add repo rancher-stable, helm repo add rancher-stable https://releases.rancher.com/server-charts/stable

Update helm repo, helm repo update

Install rancher-stable, please refer to this docs https://rancher.com/docs/rancher/v2.x/en/installation/k8s-install/helm-rancher/

helm install rancher rancher-stable/rancher — namespace cattle-system — set hostname=rancher-coba.uii.ac.id

Ssh to vm for load-balancer, 192.168.0.227

Install nginx, sudo apt install nginx –y

Config nginx, sudo vi /etc/nginx/nginx.conf

load_module /usr/lib/nginx/modules/ngx_stream_module.so;

worker_processes 4;

worker_rlimit_nofile 40000;

events {

worker_connections 8192;

}

stream {

upstream rancher_servers_http {

least_conn;

server 192.168.0.224:80 max_fails=3 fail_timeout=5s;

server 192.168.0.225:80 max_fails=3 fail_timeout=5s;

server 192.168.0.226:80 max_fails=3 fail_timeout=5s;

}

server {

listen 80;

proxy_pass rancher_servers_http;

}

upstream rancher_servers_https {

least_conn;

server 192.168.0.224:443 max_fails=3 fail_timeout=5s;

server 192.168.0.225:443 max_fails=3 fail_timeout=5s;

server 192.168.0.226:443 max_fails=3 fail_timeout=5s;

}

server {

listen 443;

proxy_pass rancher_servers_https;

}

}

Test and Reload nginx, sudo nginx –t && sudo nginx –s reload

Edit /etc/hosts in local computer/laptop

192.168.0.227 rancher-coba.uii.ac.id

Hostname rancher that we set earlier when install helm rancher.

--

--

bayu nugraha

Linux Administrator, Network Administrator, Cloud Engineer, DevOps Enthusiast, Docker, Jenkins, Git, Gitlab, Kubernetes, Ansible.