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-get remove docker docker-engine docker.io

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).


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

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 and paste the command in the terminal window.
Docker command to register host to Rancher.

6. 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.

2. Select Custom, type a Cluster Name, and click Next.

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

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


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.


Next you should also read