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.
- A Kubernetes cluster
- Rancher installed
- A Rancher-supported Docker version installed on all machines
- Sudo privileges
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.
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.
3. Next, provide a cluster name. In the expandable sections below, set up member roles and configure labels and annotations for the cluster:
4. Scroll down to Cluster Options and expand the Kubernetes Options section. Select the Kubernetes version and the network provider.
5. In the Cloud Provider subsection, select your cloud provider. Choose None if you do not wish to set up the cloud:
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:
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.
9. The command installs a docker version of a Rancher agent. The following output confirms the successful download of the container:
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 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.
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.
2. Then, click the Deploy button in the cluster dashboard.
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.
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.
To test the deployment, go to the port you assigned in Step 3. The Nginx demo page should display:
Note: phoenixNAP Kubernetes Controller for BMC allows users to provision and manage BMC server instances directly from a Kubernetes cluster.
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.
The Edit Workload page appears.
2. Type the number of pods you want to have dedicated to the workload:
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:
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.