How to Install Rancher on Ubuntu?

Photo of author

By admin

Since its inception, Kubernetes has resolved innumerable issues regarding effective management tactics for their cloud cluster storage. Due to its huge user base, the Kubernetes market should expand by over 4.3 billion USD by next year. Such an expansion would make it more than 2x as regards to its present value.

These numbers and the growth potential shows how much people are fond of the K8s technology. But sometimes, it becomes tricky to pick the right Kubernetes solution. That’s where Rancher comes in. It is, no doubt, one of the best open-source tools among the leading Kubernetes (K8s) solutions today. This article aims to discuss with you all the essential steps to install Rancher on Ubuntu with relative ease.

What Exactly is Rancher?

Before explaining the steps you have to follow to install Rancher on Ubuntu, let’s first understand what Rancher is. Well, Rancher is a wonderful invention arising out of the rapid growth of technology. Released in 2016, it is a great open-source tool for empowering companies for running containers in production. With Rancher coming to their aid, companies can ditch the need for manually constructing a container services platform. Rancher provides users with the complete software stack that they can utilize for managing their containers in production.

Let us now shift our focus to its four chief components:

1. Infrastructure orchestration

The first of its quartet of the major components is infrastructure orchestration. Rancher grasps raw computing resources from a public/private cloud. These resources come as Linux hosts. Each of such Linux hosts can either be a virtual or a physical apparatus. Plus, Rancher is also not very demanding. All it takes from the hosts is their CPU power, memory, and network connections. For Rancher, virtual machine (VM) instances of cloud service providers and bare-metal servers situated at the colocation sites are self-same.

The software also utilizes a portable infrastructure services layer specifically intended for powering containerized apps. A user gets infrastructure services like storage, DNS, networking, security, and so on from Rancher. These services get deployed as self-sufficient containers themselves, enabling them to run on all Linux hosts, regardless of the cloud.

2. Container orchestration and scheduling

The next component is the mechanism to orchestrate and schedule containers. A shedload of individuals prefers to run containerized apps via a container orchestration and scheduling foundation. For such users, Rancher incorporates an allocation of all the well-known container orchestration and scheduling frameworks out there. These include Mesos and Kubernetes among others. A single user can generate numerous Mesos or Kubernetes clusters. Rancher empowers its users to utilize their native Mesos or Kubernetes tools for managing their containerized apps.

Besides supporting Mesos, Kubernetes, etc., Rancher gives its users the ability to use a homegrown container orchestration and scheduling system known as Cattle. While initially Cattle was intended to be a Docker Swarm extension, today, it has become its own independent entity. It occurred as a result of the rapid development of Swarm and its digression from Cattle in the following years. Cattle helps Rancher immensely to configure, manage, and upgrade Mesos, Kubernetes, and Docker Swarm cultures.

3. App catalog

The third among Rancher components is its app catalog. The application catalog enables Rancher users to deploy any of their multi-container clustered apps with a single click. Just imagine how convenient and effortless that is. Users also become capable of managing the apps they’ve deployed and put them through auto-upgrades whenever a new edition of an app is out. Rancher offers a public catalog comprising all the famed apps the Rancher community has shared. Nonetheless, one is free to make their own private catalog if they want to.

4. Enterprise-grade control

The fourth and last component of Rancher is its enterprise-grade control. The software suits many user-authentication plug-ins. Plus, it has its own inbuilt authentication integration equipped with GitHub, Lightweight Directory Access Protocol, and AD. It also provides support for RBAC at its environment levels, enabling individuals and teams to give/decline ingress to deployment environments such as production and development.

Why Should You Install Rancher on Ubuntu Anyway?

Now you might think about what is the need for installing Rancher. Well, Rancher is known for offering several benefits to its users with some of them mentioned as follows:

  • Rancher’s foremost perk is its cross-host networking. No matter what your environment is, Rancher will construct a relevant private network described by software. This, in turn, leads to a safe interaction between different containers residing on different clouds/hosts.
  • The next benefit that Rancher has to offer is its container load balancing. The Rancher software provides every user with a coalescent and flexible load balancing service that functions on numerous clouds. This service helps them to dispense traffic across services/containers with ease.
  • Service discovery is yet another benefit offered by Rancher. It incorporates an inbuilt DNS-based service discovery feature equipped with a health checkup facility. This function empowers containers for auto-enrolling themselves as services. Plus, it enables those services to find other similar services on the network.
  • Effective resource management is also a stronghold of Rancher. The software provides support for Docker Machine. As some of you might know, Docker Machine is an amazing tool to perform host provisioning from CSP, ditching the need for a go-between. After the completion of the said provisioning, Rancher starts focusing on host resource overseeing and container deployment management.
  • As we said earlier, Rancher supports a plethora of container orchestration engines, including Mesos and Kubernetes. Besides that, it has its own orchestration engine, namely Cattle. The facility of using an engine of choice allows users to pick the popular orchestration engines out there. Plus, it also opens the door for enhancing Rancher features such as storage technologies, app catalog, and many more.
  • The Rancher software offers an effortless upgrade facility for the container services they possess via service cloning permission and service request diversion. Consequently, it helps to ensure the validation of the upgraded services by utilizing their dependencies prior to directing live traffic to those services.

Steps to Install Rancher on Ubuntu

In this section, we will discuss the steps that you need to follow for installing Rancher on your Ubuntu OS machine. But before talking about the steps, let’s take a look at the prerequisites for ensuring the successful installation of Rancher on Ubuntu OS.

Prerequisites

  • Two Ubuntu-installed servers
  • Two valid static IP addresses configured on each of the Rancher server and the client
  • A root password configured on both servers

Step 1: Update both servers

Before proceeding further, you have to update both of your Ubuntu-installed servers to their latest editions. Updating them is easy. Just execute the following command and that’s it:

apt-get update -y

apt-get upgrade -y

Once the update is finished, reboot both servers to implement your modifications.

Step 2: Install Docker CE

Next, you have to install Docker Community Edition (CE) on both of your servers. Typically, you won’t be able to find the latest version of Docker CE in your Ubuntu default repository. That’s why you need to add the necessary repository yourself.

For doing so, you must allow APT for utilizing a repository on HTTPS by installing some packages. Run the following commands in the terminal:

apt-get install apt-transport-https ca-certificates curl

software-properties-common -y

After that, download the GPG key for Docker Community Edition and affix it using the below command:

wget https://download.docker.com/linux/ubuntu/gpg

apt-key add gpg

After completion, join APT and the Docker CE repository together with the following command:

nano /etc/apt/sources.list.d/docker.list

Next, add this:

deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable

Once you’re done adding the above line, save the file and quit.

Now, you got to update your repository using the below command:

apt-get update -y

Upon completion, the repository will receive an update.

Next, install Docker Community Edition/CE:

apt-get install docker-ce -y

After installing Docker CE, you’d be capable of verifying the status of your Docker service using this command:

systemctl status docker

If everything went correctly, you should receive the below output:

docker.service – Docker Application Container Engine

Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)

Active: active (running) since Tue 2019-06-06 21:16:14 IST; 1min 0s ago

Docs: https://docs.docker.com

Main PID: 14498 (dockerd)

CGroup: /system.slice/docker.service

└─14498 /usr/bin/dockerd -H unix://

Jun 06 21:16:14 rancher dockerd[14498]: time=”2019-06-06T21:16:14.456058066+05:30″

level=warning msg=”Your kernel does not support swap memory

Jun 06 21:16:14 rancher dockerd[14498]: time=”2019-06-06T21:16:14.456058066+05:30″

level=warning msg=”Your kernel does not support cgroup rt pe

Jun 06 21:16:14 rancher dockerd[14498]: time=”2019-06-06T21:16:14.456058066+05:30″

level=warning msg=”Your kernel does not support cgroup rt ru

Jun 06 21:16:14 rancher dockerd[14498]: time=”2019-06-06T21:16:14.456058066+05:30″

level=info msg=”Loading containers: start.”

Jun 06 21:16:14 rancher dockerd[14498]: time=”2019-06-06T21:16:14.456058066+05:30″

level=info msg=”Default bridge (docker0) is assigned with an

Jun 06 21:16:14 rancher dockerd[14498]: time=”2019-06-06T21:16:14.456058066+05:30″

level=info msg=”Loading containers: done.”

Jun 06 21:16:14 rancher dockerd[14498]: time=”2019-06-06T21:16:14.456058066+05:30″

level=info msg=”Docker daemon” commit=4d60db4 graphdriver(s)

Jun 06 21:16:14 rancher dockerd[14498]: time=”2019-06-06T21:16:14.456058066+05:30″

level=info msg=”Daemon has completed initialization”

Jun 06 21:16:14 rancher systemd[1]: Started Docker Application Container Engine.

Jun 06 21:16:14 rancher dockerd[14498]: time=”2019-06-06T21:16:14.456058066+05:30″

level=info msg=”API listen on /var/run/docker.sock”

With your Docker CE now up and running, it’s time to install the Rancher container.

Step 3: Install the Rancher container

This step is all about installing the Rancher container in the right way. First, you have to install the Rancher image. You can obtain this image from the Docker Hub repositories. Download your Rancher container and initialize it using this command:

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

Upon successful installation, you will receive the following output:

Unable to find image ‘rancher/server:stable’ locally

stable: Pulling from rancher/server

bae382666908: Pull complete

29ede3c02ff2: Pull complete

da4e69f33106: Pull complete

8d43e5f5d27f: Pull complete

b0de1abb17d6: Pull complete

422f47db4517: Pull complete

79d37de643ce: Pull complete

69d13e08a4fe: Pull complete

2ddfd3c6a2b7: Pull complete

bc433fed3823: Pull complete

b82e188df556: Pull complete

dae2802428a4: Pull complete

effdbd93afcb: Pull complete

a4fcc35085ad: Pull complete

e8234323b6c4: Pull complete

d3f751a5d9cc: Pull complete

d4b24e84b43b: Pull complete

da9d7264902d: Pull complete

df2b31306256: Pull complete

c2238fcf71c2: Pull complete

10c7c4a52421: Pull complete

Digest: sha256:290e94536b32665d0ff537c2b947804faeed2768cd8652f0088a0d7e1acced75

Status: Downloaded newer image for rancher/server:stable

d209e25452fecc8c77cb276855bb7875c137c8b5d6ed6ba1c461c44ac877f6c7

Your Rancher server is currently about to begin and listen on port 8080. Nonetheless, you can freely change the port if you want to.

Next, launch a web browser, navigate to its URL bar, and type http://[your server IP]:[your port number]. Provided that you didn’t modify your port number, enter 8080.

Doing so will open a page. Launch the ‘ADMIN’ menu and then click ‘Access Control’. It will help you set up your Rancher Access Control. Next, navigate to ‘LOCAL’, furnish all the required info, followed by an ‘Enable Local Auth’ button click. Now, you’ve enabled your local authentication.

Step 4: Set up your Rancher client

The last step is to navigate to the Rancher server dashboard and open the ‘INFRASTRUCTURE’ menu, followed by ‘Hosts.’

After that, press the ‘Add Host’ key. This will allow you to view your Host Registration URL. ‘Save’ it. On the next page, enter your Rancher Client IP address and specify your custom host type. Next, you will receive a command that you have to paste in a designated field after signing in to your Rancher client system. The command will look something like this:

docker run -e CATTLE_AGENT_IP=”192.168.0.103″ –rm –privileged -v

/var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher

rancher/agent:v1.2.11 http://192.168.0.100:8080/v1/scripts/A7694D846BE6239EC650:

1546214400000:XOdj1phkwWhDH556B6Jb1Le2E

Once your command gets executed successfully, you will get this output:

Unable to find image ‘rancher/agent:v1.2.11’ locally

v1.2.11: Pulling from rancher/agent

b3e1c725a85f: Pull complete

6a710864a9fc: Pull complete

d0ac3b234321: Pull complete

87f567b5cf58: Pull complete

063e24b217c4: Pull complete

d0a3f58caef0: Pull complete

16914729cfd3: Pull complete

bbad862633b9: Pull complete

3cf9849d7f3c: Pull complete

Digest: sha256:0fba3fb10108f7821596dc5ad4bfa30e93426d034cd3471f6ccd3afb5f87a963

Status: Downloaded newer image for rancher/agent:v1.2.11

INFO: Running Agent Registration Process, CATTLE_URL=http://192.168.0.100:8080/v1

INFO: Attempting to connect to: http://192.168.0.100:8080/v1

INFO: http://192.168.0.100:8080/v1 is accessible

INFO: Configured Host Registration URL info: CATTLE_URL=http://192.168.0.100:8080/v1

ENV_URL=http://192.168.0.100:8080/v1

INFO: Inspecting host capabilities

INFO: Boot2Docker: false

INFO: Host writable: true

INFO: Token: xxxxxxxx

INFO: Running registration

INFO: Printing Environment

INFO: ENV: CATTLE_ACCESS_KEY=C6CB8593B0FDB118728B

INFO: ENV: CATTLE_AGENT_IP=192.168.0.100

INFO: ENV: CATTLE_HOME=/var/lib/cattle

INFO: ENV: CATTLE_REGISTRATION_ACCESS_KEY=registrationToken

INFO: ENV: CATTLE_REGISTRATION_SECRET_KEY=xxxxxxx

INFO: ENV: CATTLE_SECRET_KEY=xxxxxxx

INFO: ENV: CATTLE_URL=http://192.168.0.100:8080/v1

INFO: ENV: DETECTED_CATTLE_AGENT_IP=192.168.0.103

INFO: ENV: RANCHER_AGENT_IMAGE=rancher/agent:v1.2.11

INFO: Launched Rancher Agent: b8816fa492af46e02fb7da53096c829d2b834375fb533f5586c7ebc

6c906ab77

Now, press the ‘close’ button after navigating to your Rancher server dashboard. The following page will display your Rancher client.

And that’s all. You have successfully installed Rancher on your Ubuntu machine.

Conclusion

As you can see, Kubernetes cluster management is a pretty difficult job. Ensuring the safety and security of your containerized apps is difficult as well. However, technology has progressed a great deal since its modest origins. Consequently, handy software/tools like Rancher have arisen as lifesavers to Kubernetes users. By utilizing Rancher, constructing and managing containers and containerized applications become a lot easier.

Through this article, we have discussed with you all the steps required to install Rancher on Ubuntu. The steps are quite limited in number and are easy to comprehend. Each step, right from updating your Ubuntu-installed servers to configuring your Rancher client, has to be followed properly to make sure that Rancher gets installed successfully. All the best!

Leave a Comment