In this tutorial , We will learn how to install and configure Rancher on Ubuntu 18.04.

Lets us see how to install Rancher and setup Local authentication.

What is Rancher?

  • Rancher is an open source container management platform.
  • Rancher provides infrastructure services such as multi-host networking, load balancing, and volume snapshots.
  • It allows you to run and manage Docker and Kubernetes containers with ease.
  • Rancher allows you to build and launch Kubernetes compute nodes directly from the Rancher web interface.

Prerequisites

  • Linux host with 64-bit Ubuntu 16.04 or 18.04.
  • Minimum 4 GM of RAM.
  • Install supported version of Docker.

Install Docker on Ubuntu

Docker must be installed on the server to run rancher.

First we need to install docker on Ubuntu , As the latest stable version of docker wont be there in the default repository.

We will add the latest stable repository of docker in the system.

Run the below command , to update the packages lists for upgrading the packages and also the new packages that was added to the respository.

Update the apt package index.

sudo apt-get update

And install the below packages on the system to allow apt to use repositories over HTTPS.

sudo apt install apt-transport-https ca-certificates curl software-properties-common

Before installing the latest stable version of Docker on Ubuntu systems, First we need to remove older version of docker installed on the system, Using the below command.

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

It will delete the above listed packages and its dependencies.

Adding Docker’s official GPG Key.

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

verify the fingerprint of the key using the below command.

sudo apt-key fingerprint 0EBFCD88
rancher

Lets add the stable repository to the system.

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

Installing Docker Engine from the Repository

We have added the latest stable version of docker repository to the system.

We should update the apt index before using it.

sudo apt-get update

And install the docker engine containerd packages.

sudo apt-get install docker-ce docker-ce-cli containerd.io
rancher

If you wish to install the specific version of docker engine from the repository.First list the available versions in the repo and then run then we will install the specific version of docker.

sudo apt-cache madison docker-ce
rancher

You can find the lists of available versions of docker.

To install the specific version , Use can select the version string from the second column.

For example : 5:19.03.3~3-0~ubuntu-bionic

Lets install the above mentioned version using the below command.

sudo apt-get install docker-ce=5:19.03.3~3-0~ubuntu-bionic docker-ce-cli=5:19.03.3~3-0~ubuntu-bionic containerd.io

If you are installing custom version of docker and If the docker is already present on the system , The above commands with either Upgrade or Downgrade the docker version depending on the currently installed version of Docker.

rancher

Once the docker is installed on the system.Start the docker service and enable it on system boot.

sudo systemctl start docker
sudo systemctl enable docker
rancher

To check the status of the Docker,

sudo systemctl status docker
rancher

We have installed the latest stable version of Docker engine and the Docker service is running fine.

To check the version of the installed Docker engine ,

sudo docker --version
Docker version 19.03.3, build a872fc2f86

Installing Rancher

As we have the docker installed in the system ,We can install Rancher as a docker container on the Ubuntu Host.

sudo docker run -d --restart=unless-stopped -p 8080:8080 rancher/server
rancher

The above command will download the latest version of rancher docker image to the Ubuntu host machine.

Run the below command to list the available docker images in the system.

sudo docker images
rancher

To check the running rancher container , Run the below command.

sudo docker ps
rancher

from the above screenshot , You can see that the rancher is listening on the port 8080.

You can access the Rancher portal using IP address or domain name followed by port 8080.

http://ipaddress:8080

You will be greeted with the following screen.

rancher

What happened here is , We have accessed the Rancher portal without username and password , as the authentication is not configured yet.

Rancher supports various access control methods such as Active Directory , Azure AB , Local , GitHub , OpenLDAP and Shibboleth.

To setup an Authentication for Rancher access portal ,Under Admin click Access control

rancher

You will see the following page.

rancher

Click LOCAL , Provide the username and password to setup Admin user.

rancher

and then click Enable Local Auth.

rancher

If you can now login using username and password , which we configured as a Admin user.

You will see the following screen , While access http://ipaddress:8080

rancher

Provide the username and password and then you will be taken into rancher dashboard.

Conclusion

We have implemented Rancher on the Ubuntu operating system and also we have enabled Local authentication mechanism for the Portal.

Hope you find it helpful.Please do check out my other publications.