cloud

Deploy Rancher Kubernetes Engine

Use Rancher Kubernetes Engine to build a configurable Kubernetes cluster with Docker-based components.

Deploy Rancher Kubernetes Engine

Why use Rancher to deploy a Kubernetes cluster?

RKE is more configurable than kubeadm for my environment because several components, such as kube-dns, CoreDNS, Flannel, and StorageClass behavior, can be managed from a single cluster configuration. Upgrades can also be challenging in mixed-OS environments like mine, which includes Ubuntu 20.04.3 LTS and CentOS 7 servers. Rancher makes these differences easier to manage because the Kubernetes services run in Docker.

Rancher also configures each node over SSH, so I do not need to add worker nodes manually from the master 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
  1. 192.168.1.109: controlplane, etcd, worker (master + worker)
  2. 192.168.1.105: worker, ingress (worker)

Ingress will run on “192.168.1.105”.

Get the latest RKE binary

RKE Binary

Installation note

  1. Start building the cluster.

Make sure your cluster.yml file is 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
  1. After RKE initializes the Kubernetes cluster, use the generated kubeconfig to connect with kubectl.
    $ 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
    
  2. 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
    

Now you have a Kubernetes cluster.