How to Set Up a Kubernetes Cluster with Rancher

July 1, 2021


Rancher provides an interface for application deployment and cluster maintenance in Kubernetes. The tool gives DevOps teams a complete software stack for managing containerized apps. With Rancher, Kubernetes can be run anywhere - in a data center, or hybrid/multi-cloud environment.

This tutorial will walk you through the steps necessary to set up your Kubernetes cluster in Rancher.

How to Set up a Kubernetes Cluster with Rancher


Add a Kubernetes Cluster to Rancher

1. Select the Clusters item in the upper menu in your Rancher graphical interface and then click the Add Cluster button.

The Clusters section in the Rancher graphical interface, with the Add Cluster button on the right

Another page opens with available cluster types.

2. You can register a cluster you created before or create a new cluster using the existing nodes. This article will demonstrate the creation of a new Kubernetes cluster. Click the Existing nodes button to start the process.

Creating a new Kubernetes cluster in the Add Cluster dialogue in Rancher

3. Provide a cluster name on the next screen. In the expandable sections below, set up member roles and configure labels and annotations for the cluster:

Naming the cluster, setting up member roles and labels in Rancher

4. Scroll down to the Cluster Options and expand the Kubernetes Options section. Select the Kubernetes version and the network provider.

Managing Kubernetes options in the Cluster Options section of the Add Cluster dialogue in Rancher

5. In the Cloud Provider subsection of the Kubernetes Options, select your cloud provider. Choose None if you do not wish to set up the cloud:

Choosing the cloud provider in the Add Cluster section in Rancher

6. When you finish setting up the cluster, scroll to the bottom of the page and click the Next button.

7. On the new page, customize the command to copy and run on the machines that belong to the cluster you wish to add. Select the roles for a node:

Customizing the node run command in the Add Cluster section in Rancher

Note: Every Kubernetes cluster needs to have at least one etcd node for key-value storage and one Control Plane to maintain object records.

8. Press the blue button to copy the command below. Then execute the command on the applicable nodes.

The node run command in Rancher

9. The command installs a docker version of Rancher agent. The following output confirms the successful download of the container:

Executing the node run command on a worker node system.

10. Go to the Rancher GUI and click Done at the bottom of the Cluster Options page.

Manage the Cluster

If the cluster successfully initiates, the classic Rancher cluster dashboard is displayed.

The classic cluster dashboard in Rancher

The board provides information on the state of the cluster components. The system sends alerts when components malfunction and shows the basic system parameters - CPU, memory, and pods.

Another way to monitor the cluster is to use the Cluster Explorer. To reach the tool, click the yellow button in the upper-right corner of the page in the main menu:

The Cluster Explorer in Rancher

The Cluster Explorer offers a more compact way to monitor and manage the cluster and the deployed workloads.

Deploy a Cluster Workload in Rancher

Rancher enables you to deploy and scale Kubernetes cluster workloads easily. The following example will show you how to deploy an Nginx demo server on the cluster you created.

1. In the main menu, hover over the Global section, then the cluster name, and finally, click the Default project.

Navigating to a new project in Rancher to begin deploying a workload

2. In the cluster dashboard, click the Deploy button.

Deploying a new workload in Rancher

The Deploy Workload page displays.

3. Give a name to the deployment, assign pods, provide the name of the Docker image and the namespace for the deployment. Next, click the Add Port button and type in the necessary port configuration.

The Deploy Workload page in Rancher

4. Scroll down for more options, such as setting up environment variables, node scheduling, health checks, etc. When you finish, click Launch at the bottom of the page and wait for the workload to initiate. When the process completes, the workload will display the Active tag.

The cluster dashboard showing an active workload in Rancher

To test the deployment, go to the port you assigned as the listening port in Step 3. The Nginx demo page displays:

The Nginx demo server page

Modify a Deployment in Rancher

Rancher makes it possible to scale deployments up or down quickly. The following example will show you how to scale the number of pods of the Nginx demo server from one to three.

1. In the cluster dashboard, click the three dots on the right side of the workload item you wish to modify and choose Edit.

Editing an active deployment in Rancher

The Edit Workload page appears.

2. Type the number you want to change the number of pods dedicated to the workload:

Changing the number of pods assigned to a workload in Rancher

The page allows you to change the rest of the configuration you provided when you created the workload.

3. Click the Save button at the bottom of the page when you perform all the necessary edits.

Finally, the workload reinitiates:

The active workload after scaling up in Rancher


This tutorial showed you how to add and manage your Kubernetes cluster in Rancher. Additionally, the guide provided an example of how to create and edit cluster workloads.

Was this article helpful?
Marko Aleksic
Marko Aleksić is a Technical Writer at phoenixNAP. His innate curiosity regarding all things IT, combined with over a decade long background in writing, teaching and working in IT-related fields, led him to technical writing, where he has an opportunity to employ his skills and make technology less daunting to everyone.
Next you should read
How to Install Rancher on Ubuntu
September 2, 2020

Rancher is a container management platform that helps manage Kubernetes at scale. It makes it simple to deploy and run Kubernetes everywhere. The software is...
Read more
How to Install Rancher on CentOS 7
September 22, 2020

Install Rancher on CentOS, a container management platform used by virtualization vendors with Kubernetes in their standard infrastructure. The software simplifies deploying...
Read more
19 Kubernetes Best Practices for Building Efficient Clusters
September 23, 2020

Use the outlined Kubernetes best practices to build optimized containers, streamline deployments...
Read more
How to Set Up and Run Kafka on Kubernetes
February 12, 2020

This tutorial shows you how to configure a Kafka server on a Kubernetes cluster. Kafka is a messaging system that collects and processes extensive amounts of data...
Read more
  • © 2021 Copyright phoenixNAP | Global IT Services. All Rights Reserved.