What is Rancher?
Rancher is a software stack for managing containers. Specifically, addressing operational and security challenges of managing multiple Kubernetes clusters. It provides DevOps teams integrated tools for running containerized workloads. With Rancher you can create Kubernetes clusters with Rancher Kubernetes Engine (RKE) or cloud-based Kubernetes services, such as GKE, AKS, and EKS.
There are a number of different ways to install and setup the Rancher server. It can be installed on a single node or a high-availability Kubernetes cluster. This article serves as a tutorial for installing the Rancher server as a Docker container on a single node.
Please take note of the Rancher requirements before proceeding.
Step 1: Setup a Virtual Machine to host the Rancher Server
I used the Google Cloud Platform (GCP) to setup my virtual machine and host the Rancher server, however you could use a virtual machine from any cloud provider, or your own machine, provided it is running Docker.
With regards to the CPU and memory requirements of my virtual machine (VM), I applied the following Rancher guidelines required to host Rancher on a single-node VM:
SIZE CLUSTERS : Up to 5
NODES : Up to 50
RAM: 4 GB
With this in mind I chose a GCP Machine type: n1-standard-1 (1 vCPU, 3.75 GB memory), and I opted to install Ubuntu 16.04.7 LTS (Xenial Xerus)on the root disk.
In the setup of my VM I reserved an external IP address for the VM, so that I could point my DNS record at this VM.
Step 2: Install Docker on the VM
In order to install the Rancher server as a Docker container, you first need to install Docker itself. There are a couple of options for installing Docker -refer to the official Docker documentation about how to install Docker on Linux, as the steps will vary based on the Linux distribution.
Seeing as I used Ubuntu 16.04.7 LTS (Xenial Xerus) Ireferred to the documentation specific to installing Docker on Ubuntu. I installed Docker on my VM using the “Install using the repository” method.
Start by running the following commands to set up the Docker repository on your VM host:
Setup the repository
1.Update the apt package index and install packages to allow apt to use a repository over HTTPS:
$ sudo apt-get update
$ sudo apt-get install \
2.Add Docker’s official GPG key:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg — dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
3.Use the following command to set up the stable repository on a x86_64 / amd64 host machine:
$ echo \
“deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable” | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Install Docker Engine
1.Update the apt package index, and install the latest version of Docker Engine and containerd:
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
2.Verify that Docker Engine is installed correctly by running the hello-world image.
$ sudo docker run hello-world
Step 3: Rancher Docker Container Installation on the Single Node
Rancher can be installed by running a single Docker container.
In this installation scenario, you’ll install Docker on a single Linux host (VM), and then deploy Rancher on your host using a single Docker container.
When the Rancher server is deployed in the Docker container, a local Kubernetes cluster is installed within the container for Rancher to use. Because many features of Rancher run as deployments, and privileged mode is required to run containers within containers, you will need to install Rancher with the — privileged option.
For security purposes, SSL (Secure Sockets Layer) is required when using Rancher. SSL secures all Rancher network communication, like when you login or interact with a cluster.
I opted to install Rancher using the: “Default Rancher-generated Self-signed Certificate”.
If you are installing Rancher in a development or testing environment where identity verification isn’t a concern, install Rancher using the self-signed certificate that it generates. This installation option omits the hassle of generating a certificate yourself. However it is advised to read the Rancher SSL options, especially if you are wanting a more secure option for your Rancher server.
Install Rancher Using the Default Rancher-generated Self-signed Certificate
Note: you can choose which version of Rancher you wish to install (eg. rancher/rancher:latest OR rancher/rancher:v2.5.5)
1.Log into your Linux host (VM), and then run the following installation command to run the Rancher Docker container:
$ sudo docker run -d — restart=unless-stopped \
-p 80:80 -p 443:443 \
— privileged \
Then login to setup Rancher
To configure your Rancher instance you need to navigate to your VM’s external IP address in your browser.
You will then be prompted to choose a password and the URL of your Rancher server. I filled in my DNS name, however you could also fill in the external IP address of the VM hosting your Rancher instance. Note: you can always update your Rancher hostname later.
After completing your Rancher configuration, you are able to login to Rancher and start creating your first Kubernetes Cluster.
To learn more: