How to Install Rancher on Ubuntu

September 2, 2020

Introduction

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 especially useful as most cloud/virtualization vendors include Kubernetes as standard infrastructure.

In this tutorial, you will learn how to install Rancher on Ubuntu.

How to install Rancher on Ubuntu.

Note: Find out what makes Kubernetes a fundamental tool for managing and deploying containers in this Complete Kubernetes Guide.

Prerequisites

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

Step 1: Install Docker

1. Before downloading any new packages, always make sure to update your system:

sudo apt update

2. Uninstall any old Docker versions by running the command:

sudo apt remove docker docker-engine docker.io containerd runc

Note: If you encounter the "Unable to locate package docker-engine" error, remove the docker-engine package from the command and repeat the step 2.

3. Now you can install Docker with:

sudo apt install docker.io

4. Verify the installation was successful:

docker --version
Check Docker version on Ubuntu.

5. Start the Docker service:

sudo systemctl start docker

6. Set it to run at startup:

sudo systemctl enable docker

7. Finally, check the status of Docker:

sudo systemctl status docker
Check Docker status on Ubuntu.

The output should display the service is active (running). Exit the status output by pressing Ctrl + C.

Note: As an alternative, you can Install Docker from Official Repository.

Step 2: Install Rancher

Once you have set up Docker, use the platform to create a container where you can run the Rancher server.

1. Create a new Rancher server container using the following command:

sudo docker run -d --restart=unless-stopped -p 8080:8080 rancher/server:stable
Installing Rancher using Docker on Ubuntu.

The command above instructs Docker to run the container in detached mode and to keep it running (unless it is manually stopped). The server container is configured to listen to port 8080, but you can modify the port number according to your needs.

Docker should pull the latest Rancher image and launch the container.

2. To access the Rancher user interface, open a web browser and type the server IP number and port in the URL bar following the syntax:

https://[server_ip]:[port]
Launch Rancher on Ubuntu.

Step 3: Configure Rancher

Once you have accessed the platform, Rancher instructs you to set up the Admin user (one that has full control over Rancher).

1. Open the ADMIN drop-down menu and click Access Control.

Navigate to Access Control to configure Rancher.

2. Click the LOCAL button in the menu to move to the Local Authentication window.

Select LOCAL configuration from the access control menu.

3. Provide the required information to set up an Admin user and click Enable Local Auth to confirm.

Set up an Admin User for Rancher.

Step 4: Create a Custom Cluster

When creating a custom Kubernetes cluster on Rancher, you need to provision a Linux host (an on-premise virtual machine, a cloud-host VM or a bare metal server). Then, you can create your custom Kubernetes cluster.

Provision a Host

1. Open the INFRASTRUCTURE drop-down menu and select HOSTS.

Open Host menu on Rancher.

2. The instructions inform you that the host needs to have a supported version of Docker and allowed traffic to and from hosts on ports 500 and 4500. Start up the machine making sure it has all the specified prerequisites.

3. Rancher gives you an option to add a label to the host.

4. Provide the IP address that should be registered for this host.

Provide the IP address of the custom host you want to set up on Rancher.

5. Doing so generated a unique command which should be run on the specified host.

Copy the command that should be run on the host.

6. Copy and paste the command in the terminal window.

Pasting the host registration command in terminal.

7. Click Close and wait for the new host to appear on the Host screen.

Create a Custom Kubernetes Cluster

With the Linux host assigned, move on to creating a custom cluster.

1. Navigate to the Clusters page and click Add Cluster.

Adding a new cluster in Rancher.

2. Select Existing Nodes.

Selecting cluster type in Rancher.

3. Type a Cluster Name, and click Next.

Naming a cluster in Rancher.

4. Under Node Options, choose what roles you want the nodes to have (etcd, Control Plane, and/or Worker).

Customizing node options in Rancher.

5. In Cluster Options, chose the Kubernetes Version and the Network Provider:

Customizing the cluster options in Rancher.

6. Choose the cloud provider. If you do not have one, select None.

Selecting a cloud provider in Rancher.

5. Copy and paste the generated command on each worker node machine and wait for the cluster to start up.

Copying the command to register worker nodes in Rancher.

Note: Bear in mind that each machine within the cluster needs a supported version of Docker installed.

Conclusion

After reading this article, you should have learned how to install Rancher on Ubuntu and set up the platform to start creating Kubernetes clusters.

You might also want to check out our guide on how to install Rancher on CentOS 7 and get started with the basics.

Was this article helpful?
YesNo
Sofija Simic
Sofija Simic is an experienced Technical Writer. Alongside her educational background in teaching and writing, she has had a lifelong passion for information technology. She is committed to unscrambling confusing IT concepts and streamlining intricate software installations.
Next you should read
What is Kubernetes DaemonSet and How to Use It?
July 16, 2020

The article contains an in-depth analysis of DaemonSets and practical examples of how best to implement...
Read more
How to Deploy RabbitMQ on Kubernetes
March 6, 2020

RabbitMQ manages messaging queues and boosts communication between your loosely coupled services. This well...
Read more
How to Install Jenkins on Kubernetes Cluster
March 3, 2020

Use a provided set of YAML files to deploy scalable Jenkins on Kubernetes in 4 easy steps. Use Jenkins to...
Read more
How to Install Prometheus on Kubernetes and Use It for Monitoring
December 1, 2022

This tutorial shows you how to create a series of .yml files to set up Prometheus Monitoring on your...
Read more