Step-by-Step Guide: Installing Rancher on CentOS 7

This section describes the CentOS Rancher installation tutorial

Install Rancher on CentOS, the container management platform for virtualization vendors that use Kubernetes in their standard infrastructure. The software simplifies the deployment, operation, and management of Kubernetes at scale.

How do I install Rancher on CentOS 7? In this tutorial, you’ll learn how to install Rancher on CentOS and get started with basic configuration.

Prerequisite

  • CentOS
  • Access the command line/terminal
  • A user account with sudo or root privileges
  • Can be used for multiple nodes in a cluster

Install Rancher on CentOS

Step 1: How do I install Rancher on CentOS? Install Docker

1. Run the following command to update the system:

sudo yum check-update

2. Uninstall the old Docker version with the following command:

sudo yum remove docker docker-engine docker.io

3. Download Dependencies:

sudo yum install -y yum-utils device-mapper-persistent-data lvm2

Wait for the process to complete until you see the dependencies installed.

4. Add the official Docker repository:

sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

5. Now install Docker by running:

sudo yum install docker-ce

How to Fix Docker Installation Error

How do I install Rancher on CentOS 7? You may get an error message saying that docker-ce cannot be installed because it requires containerd.io.

To resolve this issue, install the containerd.io manually by running the following command:

yum install -y https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm

Now, repeat the Docker installation command:

sudo yum install docker-ce

Step 2: CentOS Rancher Installation Tutorial – Enable the Docker service

1. Start the Docker service and make it run on startup:

sudo systemctl start docker
sudo systemctl enable docker

2. Then, check the service status:

sudo systemctl status docker

The output should show that the service is active (running).

Step 3: Install Rancher

1. How do I install Rancher on CentOS? Use the following command to start a Rancher server inside a Docker container:

docker run -d --restart=always -p 8080:8080 rancher/server:stable

Docker pulls the latest stable Rancher image and starts the container. The above command runs the container in detached mode (-d) and keeps it running (--restart=always) listening on port 8080.

Note: docker run Learn more about the many different ways to command and run containers by looking at how to run commands and examples using Docker.

2. Check if the Rancher server is running by listing the existing docker containers that are running:

docker ps

You should see the Rancher container in the output.

3. You can now open the Rancher user interface by navigating to the server IP number and port in the URL bar.

CentOS Rancher Installation Tutorial: Configuring Rancher

How do I install Rancher on CentOS 7? The basic Rancher configuration outlined in the following steps will help you create an admin user and start a Kubernetes cluster.

Step 1: Set up an admin user

The first thing you need to do after launching Rancher is to set up an admin user.

1. Click on the ADMIN drop-down menu and select Access Control.

2. Select Local Configuration to move to the Local Verification window.

3. Fill in the required information to set up the admin user. Then, click Enable Local Identity Verification to confirm.

Step 2: Configure the host

1. Select the Infrastructure drop-down menu and click Hosts.

2. Start the machine, make sure it has a supported version of Docker, and allow traffic to and from the host on ports 500 and 4500.

3. Add the IP address of the host.

4. Copy and paste the generated command into the terminal window of the machine.

5. Turn off and wait for the new host to appear on the Host screen.

Step 3: Create a custom Kubernetes cluster

1. How do I install Rancher on CentOS? Open the Clusters page and select Add Cluster.

2. Select Custom, provide the Cluster Name, and click Next.

3. Select the role you want the node to have from the Node Options (etcd, Control Plane, and/or Worker).

4. Copy and paste the generated commands onto each minion machine. Each machine in the cluster must have a supported version of Docker installed. Finally, wait for the cluster to start.

Note: For more details on managing clusters with Rancher, see our in-depth guide on how to set up a Kubernetes cluster with Rancher.

CentOS Rancher Installation Tutorial Conclusion

How do I install Rancher on CentOS 7? By the time you read this article, you should have successfully installed the Rancher server in a Docker container.

When setting up a Kubernetes cluster, make sure to protect your workloads. To learn more about how to do this, see Kubernetes security best practices.