How to Install Rancher on CentOS 7?
Kubernetes has acquired tons of fame nowadays. The main reasons behind this growing popularity are the convenience and efficacy offered by Kubernetes. However, people who’re using Kubernetes may be well aware of the difficulty associated with the deployment of a containerized app. In fact, the difficulty level is so high that even the most skillful IT personnel find themselves in deep puzzlement sometimes. And that’s exactly where technological innovations like Rancher come into the picture.
Rancher is an awesome tool intended to ease the procedure of deploying containers and containerized apps. This article aims to act as your lodestar on how you can install Rancher on CentOS 7. So, continue reading till the end.
Rancher arose out of the rapid development of technology and the increasing popularity of Kubernetes. It was launched back in May 2016. Rancher is a great piece of software that helps organizations to get rid of the want or need of the manual construction of a container services platform. Also, it is an open-source tool, paving the way for constant bug fixes and updates. By offering an entire software solution to the users, Rancher helps easily manage their containers in operation.
There are three primary methods (primary consumption interfaces) via which users may interact with the Rancher tool:
- Users may utilize the native Docker CLI/API. Rancher doesn’t offer native Docker experience to cloud users’. Instead, it functions in the background. This, in turn, leads to users getting both native Docker and Rancher benefits.
- Users can also access Rancher via a CLI tool, namely, rancher-compose. This tool allows users to hoist numerous Docker Compose templates on Rancher. Plus, the rancher-compose tool goes well with the typical docker-compose.yml format, giving way to extensions and overwriting service definitions using a discretionary rancher-compose.yml file.
- The last is the Rancher UI. One-time setup tasks like environment management, access control configuration, etc., need this Rancher UI. It’s simple and easy to use, contributing to greater convenience.
What Makes Rancher Different from Other Similar Platforms?
There are a few features that make Rancher different from other similar tools available out there. Here are what makes the software stand out:
1. Open-source facility
As we mentioned earlier, Rancher is 100% open-source. This makes Rancher more flexible than its closed-source counterparts. If you look at the K8s management platforms today, you will be surprised to see that most of them pose some restrictions. These restrictions confine users to their environment only. Some legacy vendors also like to take things further by importuning users to opt for their own costly tools. Picking such a platform could end up turning you away from Kubernetes’ core, making it tougher to switch platforms in case your new needs demand it.
On the contrary, Rancher suits numerous K8s distributions such as RKE, as long as it’s CNF-certified. Besides that, the tool also incorporates famed open-source projects like Grafana, Istio, and so on, making Kubernetes more fruitful.
2. Day 2 multi-cluster K8s functions
Rancher incorporates Day 2 multi-cluster facility. It allows users to install and set up multiple K8s clusters anywhere from on-premises to at the edge. After successful configuration, Kubernetes deals with all the day 2 functions for your multi-cluster K8s deployment.
It controls access to your K8s clusters via a centralized role-based access control and performs the deployment of multi-cluster Kubernetes apps from your catalog. Besides that, it oversees the health status of workloads using health checkup tools like Grafana and Prometheus. Suppose there occurs any failure regarding the deployment of K8s apps. In that case, you will get notified via text messages, Slack, email, or PagerDuty. Also, Rancher helps link various clusters to existing CI/CD pipelines in services like GitLab, Travis, Jenkins, and so on.
Steps to Install Rancher on CentOS 7
Now coming to the focal part of the guide, that is, the steps required to install Rancher on CentOS 7. But before proceeding further, let’s first take a look at the prerequisites for installing Rancher on CentOS.
- A CentOS 7 system with two hosts
- Root privileges
Step 1: Install Docker on CentOS 7
You can install your Rancher tool as a Docker container set. Among this set, one container has to be a management server and the other one an agent. For that purpose, we got to install Docker on both the host and the agent.
So, first, install Docker on your CentOS 7 computer using the below command:
yum -y install docker
Once the installation is successful, begin the Docker service and attach that to your boot time with the following commands:
systemctl start docker
systemctl enable docker
Now, utilize the following command to verify if the Docker service installation on your Rancher host server was a success:
systemctl status docker
If the installation is successful, you’d get an output specifying the docker version.
Step 2: Install Rancher Server
The next step is to install the Rancher server and run it. For doing so, you have to run your Rancher container on your host server.
Here, you need to install the Rancher server single container on your first host server. But before doing that, you have to create and specify a new directory as a Rancher DB volume.
Thus, execute the command below:
mkdir -p $HOST_VOLUME
After that, install the Rancher server utilizing this command:
sudo docker run -d \
-v $HOST_VOLUME:/var/lib/mysql \
-p 8080:8080 \
Wait for some time and let the Rancher server installation finish. Once it’s finished, you will be capable of accessing the Rancher server via your browser.
Now, navigate to your browser’s address bar and type http://, followed by [your server IP address]:[your port number]. Unless you modify it yourself, your port number will be 8080.
Doing so will take you to the Rancher welcome page. It signifies that Rancher is up and running on port no. 8080 on your CentOS 7 system.
Step 3: Enable Local Authentication on your Rancher Server
After your Rancher server has begun running, there are numerous other important tasks left to execute. The first among those is to set up the Rancher access control. Doing so will let you manage users possessing access to your Rancher server.
Besides local authentication, Rancher harmonizes well with multiple access control providers such as Azure AD, SAML, Active Directory, etc.
For enabling Local Authentication on your Rancher server, launch your preferred browser and go to its URL bar and enter http:// followed by your server IP address and port number.
Next, pick ‘Access Control’ from the ‘ADMIN’ menu on the Rancher welcome page. Then, click ‘LOCAL’ and provide your login credentials.
Press the ‘Enable Local Auth’ button, and that’s it. You have successfully enabled Local Authentication.
Step 4: Add a New Host
Within Rancher, hosts are considered as the most rudimentary resource unit. Rancher also embodies them as any other Linux server (a Docker-installed physical/virtual server).
Here, you have to attach a new Ubuntu-installed host with a minimum of 2 GB RAM.
Establish connection to this new host via SSH utilizing this command:
Next, install Docker on your host using the below command:
yum -y install docker
Upon the completion of the installation process, launch Docker and make it begin each time your system restarts:
systemctl status docker
After the Docker installation is finished on your new host, we will add it to your Rancher as a host. For that, you need to launch the Rancher dashboard and go to ‘INFRASTRUCTURE’, followed by ‘Hosts’. Next, click ‘Add Host’ and enter the default Host Registration URL in the designated field. Once done, press the ‘Save’ button.
After that, you need to choose your Host type. Select ‘Custom’ and type your new host’s IP address. Also, don’t forget to copy the Docker command.
Next, launch your new host’s terminal and paste the command following:
sudo docker run -e CATTLE_AGENT_IP=”192.168.33.11″ –rm –privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.2.10 http://192.168.33.10:8080/v1/scripts/BCF2EFCA73A02954EBDF:1514678400000:OdRDdvnEUbV2hUMAFIS3oQxcTt4
Doing so will download the new Rancher agent container and run it. Upon flawless completion, you will receive an output confirming so.
Now, upon going back to the preceding page, click ‘Close’. With that, the new host has become a part of your Rancher server.
Step 5: Create a New Container for Testing
After everything is done, it’s best to check if the process went well. For that purpose, create a demo container, for instance, Ghost.
Doing so is easy. From the Rancher dashboard, go to ‘CATALOG’, followed by ‘Community Catalog.’ Next, in the search box, enter your container name (in this case, Ghost) and press the ‘View Details’ button. Assign a new name and description to your Ghost container and press ‘Launch.’ Once completed, you will see ‘Active’ written before your container name.
Your Ghost container is up and running now. Navigate to ‘INFRASTRUCTURE’ and press ‘Host.’ Here, you must ensure that your Ghost container runs on your new host server.
You can verify if your Ghost container installation was successful by going to your browser and typing your new host server IP address. It will take you to the default welcome page of the Ghost blog.
That’s all. Your Rancher installation on CentOS 7 is completed successfully.
As you can see, the process to install Rancher on CentOS 7 is nothing fancy. By simply following the steps mentioned above, you too can do it with ease. Every step has to be adhered to religiously. From installing Docker to your CentOS 7 to adding a new host – do everything systematically, and there’s nothing to fret about. Also, it’s crucial that you create a demo container to see everything is working fine. Here, we took Ghost as our demo. But, you’re free to pick any container that you desire.
It’s a known fact that Rancher has been a great solution to all K8s container deployment-related problems. Kubernetes, while being an amazing platform, is infamous for container deployment complexities. That’s why tools like Rancher become necessary, almost an essential part of the K8s world. Besides its efficiency, Rancher’s pure open-source facility and multi-cluster support have contributed to it being a maverick among similar platforms. If you too suffer from deployment issues regarding containers and containerized apps in Kubernetes, you shouldn’t misspend any more of your time. Utilize this guide, install Rancher on your local machine with ease. Good luck!