Why use Rancher to deploy a Kubernetes cluster?
RKE is a better fit than kubeadm for my environment because it lets me manage components such as kube-dns, CoreDNS, Flannel, and StorageClass behavior from one cluster configuration. Upgrades can also be difficult in a mixed-OS environment like mine, which includes Ubuntu 20.04.3 LTS and CentOS 7 servers. Rancher reduces the effect of those differences by running Kubernetes services in Docker.
Rancher also configures each node over SSH, so I do not have to join workers manually from the control-plane node.
This is an example RKE cluster.yml configuration.
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.DOMAIN_NAME
user: USER_NAME
password: USER_PASSWORD
is_default: false
192.168.1.109: control plane, etcd, and worker.192.168.1.105: worker and ingress.
Ingress runs on 192.168.1.105.
Get the latest RKE binary
- Build the cluster.
Make sure cluster.yml is in the same directory as the RKE binary. RKE runs on most Linux distributions with Docker installed.
Reference: general-linux-requirements
$ ./rke up
INFO[0000] Building Kubernetes cluster
...
INFO[0101] Finished building Kubernetes cluster successfully
- After RKE initializes the cluster, use the generated kubeconfig to connect with kubectl.
$ cp kube_config_cluster.yml ~/.kube/config
By default, kubectl reads ~/.kube/config. Use --kubeconfig to specify a different path. For example:
kubectl --kubeconfig /custom/path/kube.config get pods
- Check node 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
