Install Rancher

How to install Rancher in minutes on Ubuntu

Rancher is a great tool to manage and orchestrate Kubernetes clusters on different platforms. In this article, I will guide you on how to install Rancher in a small environment and also show you how to deploy a cluster.

Prerequisites

The first thing you need to do is to install a clean Ubuntu server. For this article, I have used version 20.04.5 LTS, which is the latest version supported by Rancher at this time.

You can check your version with this command.

lsb_release -a

And this is the output:

Distributor ID: Ubuntu
Description: Ubuntu 20.04.5 LTS
Release: 20.04
Codename: focal

As always, it is always a good idea to update all patches before getting started. To do that, run this command.

sudo apt update && sudo apt upgrade -y

Installing Docker

Now, we are ready to install Docker. To make things easier, we are going to use one of Rancher’s installation scripts. Use the following command to install Docker.

curl https://releases.rancher.com/install-docker/20.10.sh | sh

Add user to the Docker group

To be able to run Docker commands, you need to add your user to the docker group since your user is not root. Use the following command to add your user to the docker group.

sudo usermod -aG docker $USER && newgrp docker

After you have applied the command, you can test by typing the following command.

docker -v

If the executes without asking for your password, it works.

Installing Rancher

Now we have installed docker, and we can now run containers on our Ubuntu box. The command below will download the latest docker image from Docker Hub and spin up a container. The command is from the Rancher documentation, which you can find here:

https://www.rancher.com/quick-start

docker run --privileged -d --restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher

Once the image is downloaded and the container is deployed, you can access Rancher.

Access Rancher for the first time

When the deployment is done, you can access the Rancher UI by accessing http://HOST_IP or https://HOST_IP.

How to install Rancher

When you access the UI for the first time, you can see that you need to type commands into your host to get the bootstrap password. First, you need the container ID of the Rancher container. You can the container ID with this command.

docker ps

The command will give you a list of all active containers running on your host. The container ID is the string of characters and numbers far to the left. In this case, the number is 6d664696c36d

docker container id

The next command is also in the setup window. Switch container ID with your own container ID that you got from the previous command.

docker logs container-id 2>&1 | grep "Bootstrao Password:"

You now have the bootstrap password for Rancher. When you log in, you will be able to choose from a randomly generated password or choose your own.

rather-bootstrap-password

You have now successfully installed Rancher and you are now ready to deploy your first Kubernetes cluster.

Leave a Reply

Your email address will not be published. Required fields are marked *