Why I use Rancker to deploy Kubernetes Cluster?
RKE is more easily and configurable. If we use kubeadm, we need to config many components by ourself. (like kube-dns, coredns, flannel, storageClass).
Upgrade is also a difficult job. Especially, one of my server is running Ubuntu 20.04.3 LTS, another is running Centos 7. Although this is not a good choice to use two different OS. With Rancher is more comfortable to deal with different environment.
Rancher using ssh to config each nodes. You don’t need to set worker node join to master node one by one.
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.
- Start build cluster.
Ensure you have your own cluster.yml in same folder.
RKE runs on almost any Linux OS with Docker installed.
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
Editing…