How to Set Up a Kubernetes Cluster with Rancher

Introduction

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 a 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

Prerequisites

Add a Kubernetes Cluster to Rancher

1. Select the Clusters item in the menu bar of 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

A new page with available cluster types opens.

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. Next, provide a cluster name. 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 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, 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. Next, customize the command you will run on your existing machines. Start by selecting the roles for the node:

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

Note: Every Kubernetes cluster needs 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 a 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

You should see the classic Rancher cluster dashboard if the cluster successfully initiates, similar to the image below.

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 use the tool, click the yellow button in the upper-right corner of the page in the main menu.

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

The Cluster Explorer in Rancher

Deploy a Cluster Workload in Rancher

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

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

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

2. Then, click the Deploy button in the cluster dashboard.

Deploying a new workload in Rancher

The Deploy Workload page displays.

3. Give a name to the deployment, assign pods, and provide the Docker image’s name and the namespace for the deployment. Next, click Add Port 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 displays the Active tag.

The cluster dashboard showing an active workload in Rancher

To test the deployment, go to the port you assigned in Step 3. The Nginx demo page should display:

The Nginx demo server page

Modify a Deployment in Rancher

Rancher makes it possible to scale deployments up or down quickly. The following example shows 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. Then, choose Edit.

Editing an active deployment in Rancher

The Edit Workload page appears.

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

Changing the number of pods assigned to a workload in Rancher

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

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

Finally, the workload reinitiates:

The active workload after scaling up in Rancher

Conclusion

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.

原创文章,作者:carmelaweatherly,如若转载,请注明出处:https://blog.ytso.com/224091.html

(0)
上一篇 2022年1月7日
下一篇 2022年1月7日

相关推荐

发表回复

登录后才能评论