Why use Rancher to deploy a Kubernetes Cluster?
RKE is more configurable than kubeadm, which requires manual configuration of several components, such as kube-dns, coredns, flannel, and storageClass. Upgrading can also be challenging, particularly in mixed-OS environments like my setup, which has servers running Ubuntu 20.04.3 LTS and Centos 7. Rancher makes it more convenient to manage these differences. Because all rancher’s k8s services will run in Docker.
Moreover, Rancher configures each node using ssh, eliminating the need to add worker nodes individually to the master node.
This is a RKE example config cluster.yml.
nodes:
- address: 192.168.1.109
user: node
role:
- controlplane
- etcd
- worker
- address: 192.168.1.105
user: node
role:
- worker
ssh_key_path: /home/node/.ssh/udoo
labels:
app: ingress
cluster_name: mycluster
ignore_docker_version: false
ssh_key_path: /home/node/.ssh/rke_rsa
ssh_cert_path: /home/node/.ssh/rke_rsa.pub
kubernetes_version: "v1.20.11-rancher1-2"
ingress:
provider: nginx
network_mode: hostPort
http_port: 8888
https_port: 9999
node_selector:
app: ingress
private_registries:
- url: registry.DOAMIN_NAME
user: USER_NAME
password: USER_PASSWORD
is_default: false
- 192.168.1.109: controlplane, etcd, worker (master+worker)
- 192.168.1.105: worker, ingress (worker)
Ingress will run on “192.168.1.105”.
Get the latest RKE binary.
- To start building the cluster
Make sure you have your own cluster.yml file in the same folder. RKE runs on almost any Linux OS with Docker installed.
Reference: general-linux-requirements
$ ./rke up
INFO[0000] Building Kubernetes cluster
...
INFO[0101] Finished building Kubernetes cluster successfully
- After RKE init our new kubernetes clsuter. kubectl will use this secret to connect our cluster.
$ cp kube_config_cluster.yml ~/.kube/config
By default, kubectl checks ~/.kube/config for a kubeconfig file, but you can use any directory you want using the –kubeconfig flag. For example:
kubectl --kubeconfig /custom/path/kube.config get pods
- Let’s check nodes status.
➜ $ kubectl get node NAME STATUS ROLES AGE VERSION 192.168.1.105 Ready worker 36d v1.20.11 192.168.1.109 Ready controlplane,etcd,worker 36d v1.20.11