In this blog, we’re demonstrating how to use a container tool to create a gossip-based Kubernetes cluster using Rancher (RKE).
The rancher is an enterprise open source tool much like Kubernetes and Swarm container orchestration and it’s very simple to use.
Two steps we will be performing:
- Installing Rancher
- Creating a k8s cluster using rancher.
We have two options available to install Rancher:
- Single node installation
- High availability installation.
Single Node Installation: Install rancher in single Linux node; this is for development and testing purposes. Click here for more details on Rancher single node installation.
High Availability Installation: Installing and configuring Rancher on a cluster mode for production mode is recommended by Rancher. Click here for more details on Rancher high availability installation.
Here in this article, we will perform a single node installation.
Rancher is a simple Docker container; we just need to spin up the Rancher container.
Note: The above command does not persist the storage; if we want to store the data, add -v /opt/rancher:/var/lib/rancher to the command.
After the container is up and running, you can access the UI on “https” and the first screen will ask you to set password need to set the password for the rancher.
After setting password you will see below page as shown below:
Creating K8s Clusters Using Rancher
There are three ways to create clusters:
- Rancher UI
- Rancher API
- Rancher CLI
Here we are going with Rancher UI.
To create a k8s cluster, click on Add Cluster. Here are the options:
Rancher gives you four options to install and configure K8s cluster.
- Hosted Kubernetes provider
- From nodes in an infrastructure provider.
- Import existing K8s cluster.
- From my own existing node.
We are going with “From Nodes in an infrastructure provider” with AWS EC2 instance.
Click here for more details on the above options.
Before going with AWS EC2, there are some prerequisite steps need to follow:
- Create a policy with EC2 full access rights and assign that policy to a user in AWS IAM.
- Add the IAM policy to the permission user.
- Generate the AWS security access key pair of above user.
In Rancher, the K8s cluster contains three nodes:
- control panel
etdc: etdc node runs the database; it will store the Kubernetes state in key-value pair. etdc node is very important because every event done in the Kubernetes cluster will store in this node only. So for high availability of this node, Rancher suggests user 1 or 3 or 5 or more nodes.
control panel: control panel node runs Kubernetes Scheduler, API manager and Control manager.
worker: worker node runs kubelets and pods and containers.
Click here for more details on the above nodes.
We need to configure Node pools as shown below.
Here I am trying to create all the three components in 1 node
Before going forward, we need to add Node Template
Here we need to supply the AWS Access key pair for the Authenticate and Configure node template.
Here I am installing a cluster in the us-west-2 region
In the Instance section, we need to note the instance type and AWS EC2 AMI ID for the particular region which we are installing Kubernetes.
Click on Create to create cluster process. This will take some time to complete the process.
We can create a multi-node Kubernetes cluster using Rancher and scale up and scale down multiple nodes, pods and highly available Kubernetes cluster.