How to Install Rancher on CentOS 7 {+Deploying a Cluster Explained}

Introduction

Install Rancher on CentOS, a container management platform used by virtualization vendors with Kubernetes in their standard infrastructure. The software simplifies deploying, running, and managing Kubernetes at scale.

In this tutorial, you will learn how to install Rancher on CentOS and get started with basic setup.

Prerequisites

A CentOS

  • system
  • Access to a command line/terminal A
  • user account with sudo or root privileges
  • Multiple nodes you can use for your cluster

Install

Rancher on CentOS

Step 1: Install Docker 1

. Update the system by running:

sudo yum check-update

2. Uninstall older versions of Docker with:

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 finish until you see that dependencies have been 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 resolve

Docker installation error

You may get an ERROR saying that the system cannot install docker-ce because it requires containerd.io.

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

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: Enable the Docker 1 service

. Start the Docker service and enable it to run at boot:

sudo systemctl start docker sudo systemctl enable docker

2. Then, check the status of

the service: sudo systemctl status docker

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

Step 3: Install Rancher

1. Start the Rancher server inside a Docker container with the command

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

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

2. Check if the Rancher

server is running by listing the existing docker containers in running state: docker

ps

You should see the Rancher container listed in the output

.

3. You can now open the Rancher UI by navigating to the server’s IP number and port in the URL bar.

Configuring Rancher

The basic Rancher configuration described in the steps below will help you create an administrator user and launch a Kubernetes cluster

.

Step 1: Configure

the administrator user

The first thing you need to do after starting Rancher is to configure the administrator user

.

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

.

2. Select LOCAL Settings to proceed to the Local Authentication window.

3. Complete the information required to set up an administrator user. Then click Enable local authentication to confirm.

Step 2: Provision a host

1. Select the INFRASTRUCTURE drop-down menu and click HOSTS.

2. Power on the machine making sure it has a supported version of Docker and allows traffic to and from hosts 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. Close and wait for the new host to appear on the Host screen.

Step 3: Create a custom Kubernetes cluster

1. Open the Clusters page and select Add Cluster.

2. Choose Custom, provide a Cluster Name, and click Next.

3. Choose which roles you want the nodes (etcd, control plane and/or worker) to have from the node options.

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

Conclusion

After reading this article, you should have successfully installed a Rancher server inside a Docker container

.

When configuring Kubernetes clusters, make sure you protect your workloads. For more information on how to do this, see Kubernetes security best practices.

Contact US