Step 1 – Install docker
Step 2 – Install RKE
URL to download – https://github.com/rancher/rke/releases
$ sudo yum install wget -y
$ wget https://github.com/rancher/rke/releases/download/v1.3.10/rke_linux-amd64
$ chmod 755 rke_linux-amd64
$ mv rke_linux-amd64 rke
$ echo $PATH
$ sudo mv rke /usr/sbin
Step 3 – Add normal user to docker group
$ sudo groupadd docker
$ sudo gpasswd -a $USER docker
$ docker ps
Step 4 – Create rke config file
[centos@ip-172-31-11-29 ~]$ rke config
[+] Cluster Level SSH Private Key Path [~/.ssh/id_rsa]:
[+] Number of Hosts [1]: 1
[+] SSH Address of host (1) [none]: 172.31.11.29
[+] SSH Port of host (1) [22]:
[+] SSH Private Key Path of host (172.31.11.29) [none]: ~/.ssh/id_rsa
[+] SSH User of host (172.31.11.29) [ubuntu]: centos
[+] Is host (172.31.11.29) a Control Plane host (y/n)? [y]: y
[+] Is host (172.31.11.29) a Worker host (y/n)? [n]: y
[+] Is host (172.31.11.29) an etcd host (y/n)? [n]: y
[+] Override Hostname of host (172.31.11.29) [none]: host1
[+] Internal IP of host (172.31.11.29) [none]: 172.31.11.29
[+] Docker socket path on host (172.31.11.29) [/var/run/docker.sock]:
[+] Network Plugin Type (flannel, calico, weave, canal, aci) [canal]: weave
[+] Authentication Strategy [x509]:
[+] Authorization Mode (rbac, none) [rbac]:
[+] Kubernetes Docker image [rancher/hyperkube:v1.22.9-rancher1]:
[+] Cluster domain [cluster.local]:
[+] Service Cluster IP Range [10.43.0.0/16]:
[+] Enable PodSecurityPolicy [n]:
[+] Cluster Network CIDR [10.42.0.0/16]:
[+] Cluster DNS Service IP [10.43.0.10]:
[+] Add addon manifest URLs or YAML files [no]:
[centos@ip-172-31-11-29 ~]$
Step 5 – Run rke up command
Follow this documentation to set up a highly available Kubernetes cluster on Ubuntu 20.04 LTS machines using Rancher's RKE.
This documentation guides you in setting up a cluster with three nodes all of which play master, etcd and worker role.
Role | FQDN | IP | OS | RAM | CPU |
---|---|---|---|---|---|
Master, etcd, worker | node1.example.com | 172.16.16.101 | Ubuntu 20.04 | 2G | 2 |
Master, etcd, worker | node2.example.com | 172.16.16.102 | Ubuntu 20.04 | 2G | 2 |
Master, etcd, worker | node3.example.com | 172.16.16.103 | Ubuntu 20.04 | 2G | 2 |
- Password for the root account on all these virtual machines is kubeadmin
- Perform all the commands as root user unless otherwise specified
If you want to try this in a virtualized environment on your workstation
- Virtualbox installed
- Vagrant installed
- Host machine has atleast 8 cores
- Host machine has atleast 8G memory
vagrant up
We will be using SSH Keys to login to root account on all the kubernetes nodes. I am not going to set a passphrase for this ssh keypair.
ssh-keygen -t rsa -b 2048
The root password is kubeadmin
ssh-copy-id root@172.16.16.101
ssh-copy-id root@172.16.16.102
ssh-copy-id root@172.16.16.103
ufw disable
swapoff -a; sed -i '/swap/d' /etc/fstab
cat >>/etc/sysctl.d/kubernetes.conf<<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system
{
apt install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt update && apt install -y docker-ce=5:19.03.10~3-0~ubuntu-focal containerd.io
}
rke config
Once gone through this interactive cluster configuration, you will end up with cluster.yml file in the current directory.
rke up
Once this command completed provisioning the cluster, you will have cluster state file (cluster.rkestate) and kube config file (kube_config_cluster.yml) in the current directory.
On your host machine
mkdir ~/.kube
cp kube_config_cluster.yml ~/.kube/config
kubectl cluster-info
kubectl get nodes
kubectl get cs
Have Fun!!
I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I am working at Cotocus. I blog tech insights at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at I reviewed , and SEO strategies at Wizbrand.
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at PINTEREST
Rajesh Kumar at QUORA
Rajesh Kumar at WIZBRAND
How to setup with containerd instead of docker?