Install Rancher 2 on Single Node

Adam Vegert
Feb 9 · 5 min read

At the moment of writing this article, the latest version of Rancher is 2.3.5. So this article going through how to install the version as mentioned above, step by step.

First things first, so let’s check what the requirements of this version are, and what we should prepare for a successful installation.

Note that: This type of installation is not suitable for a production environment, this works for testing or presenting purposes!


Preparation

We need a computer where we can run the defined OS for Rancher. A VPS (Virtual Private Server) can be suitable for this purpose. To set up this, I will use a server from DigitalOcean, where the VPS has a fantasy name that calls Droplet. After a quick registration, you will get $100 that you can use for 60 days.

There are some useful settings that we should apply before we create our first Droplet.

  1. Install an SSH client on our computer.
  2. Generate an SSH key that allows connecting to VPS without password authentication. This method’s more secure than password authentication.

There are plenty of SSH client on the market, but if you can’t choose among the crowd, my advice is Putty. This is a free application and enough for us now. Please download and install it.

To generate ssh key open Command prompt from Start menu and run the following command:

ssh-keygen

The terminal asks you to enter some file name for the key, but instead of change it, please press Enter to accept and press enter two more times to a successful generation. Note that in the production environment useful to setup passphrase.

Now please open the start menu and run PuTTYgen. Click on the Load button and select “All Files” filter instead of “PuTTY Private Key Files (*.ppk) on the left bottom to see id_rsa file (Located in: C:Users/USER/.ssh/id_rsa). Appear an info popup from PuTTYgen, just click OK. Under the Load button, please click “Save private key” button with the following name “id_rsa_priv.ppk” to the same location as we worked before.

Please login to DigitalOcean and click the Security menu on the left sidebar, under the Account group. Next, please select the Security tab on the top menu. On the right side of the SSH keys section, you can find the Add SSH key button. After you click on, it appears a popup window where you can insert the content of your id_rsa.pub file(Located in: C:Users/USER/.ssh/id_rsa_priv) with open a file with a notepad and copy the content. Enter some name for the key and click on Add SSH key button.


Create our first Droplet

Click on the left pane for Droplets, and please click on Create a Droplet button.

Create Droplet

On the Create Droplet screen, you should select an OS for your installation. Here you can find the supported operation system. Now I will use CentOS 7.

The next step is to choose the plan. Now we enough to choose Standard package and please select the machine with the following setup:

  • 4 GB memory
  • 2 CPU
  • 80 GB SSD

According to the documentation, these are the recommended resources.

CentOS 7, 2 CPU, 4GB Memory

Now we have to select a data center region. My advice is that, please select the closest location to you. In my case, I will use Frankfurt.

If we are going further, we can see the default Authentication method is SSH keys with the key that we already added before.

Finally, you have to click on Create droplet button at the end of the form.

This setup cost $20 for a month but don’t worry if this cost is more than you expected, please notice Droplet pricing based on an hourly basis.

Please wait until the line of creating will be 100%, and please copy the IP address of the Virtual Machine.


Connect to Droplet(VM) from your local computer

Go back to your computer and open the Putty SSH client.

Into the “Host Name” field, please insert the IP address that you copied before. We need some further setup to authenticate with the ssh key. On the left side of Putty, please click Connection ->SSH -> Auth tab.

Here you can find the “Private key for authentication” field at the bottom of the window. Click on “Browse…” button to setup Private key location(Located in: C:Users/USER/.ssh/id_rsa_priv.ppk), select the file and click on open. Now we need to set up the Auto-login user name, which you find under Connection -> Data menu. Please type “root”.

Go back to the Session tab and click on the field that under the Saved session and give a name for this setup like “Rancher Droplet”. Finally, please click the save button.

Now we can connect to our Droplet if we click on open. There is open a popup button about the SSH key, and please accept it.


Working in terminal

First, run this command:

yum update -y

This command ensures our system updated with the latest software packages. This process takes some minutes to finish, please be patient.

Install Docker and Rancher 2

To run Rancher on a Virtual machine, we need to install docker first. There is an excellent automatic installation script. To run this, please run the following command in terminal of Droplet:

curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh

You will get a warning at the end of the install but please don’t care about it. At the moment, this is not important.

You can find this script: https://github.com/docker/docker-install.

Now start the docker daemon:

sudo systemctl start docker

Now we are capable of running out Rancher instance with the following code:

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

Open your browser and insert the IP address of the Droplet. For the first time, you will get an SSL error. If you are in Chrome, click on Advance and Proceed to the website button.

Here we go to set up a new password for the admin user. Let’s fill the field for a password and click Continue.

On the next screen, you can have to click the Save URL button. During this installation, we didn’t use any Domain name, thus leave is like as it auto-filled.

Now you can test and get some experience in Rancher.

If you like this article, please follow me for further technical content.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade