Install Rancher in 15 minutes: Kubernetes made easy

Install Rancher in 15 minutes: Kubernetes made easy

Picture this: You’re an architect, and you’re tasked with building a house. You have your blueprint (technical documentation), your construction materials (Kubernetes), and your tools (Rancher, RKE2, Longhorn). But, navigating through the blueprint while juggling the materials and tools can be like trying to find your way through a labyrinth without a map. Sounds daunting, doesn’t it? But what if there was a guide to simplify it all?

Welcome to our comprehensive guide to setting up Kubernetes, where we will unravel the complexities of the Kubernetes ecosystem, much like a guide helping you navigate through the labyrinth. We’ll highlight the essential tools you need to make it manageable and efficient, akin to picking the right construction materials and tools to build your house. This guide will provide unique insights into the flexibility and ease of use of Rancher, a powerful tool that is revolutionizing cluster management, just like an innovative construction tool that changes the game.

Our objective? To provide you with a step-by-step guide to building your ‘house’, i.e., installing Kubernetes, RKE2, Rancher, and Longhorn, with a special focus on the unique features and capabilities of Rancher. So, if you’re ready to dive into the world of Kubernetes and Rancher, put on your architect’s hat, and let’s get started!

TL;DR: What is this guide about?

This guide provides a comprehensive and practical approach to setting up Kubernetes using tools like RKE2, Rancher, and Longhorn. It aims to simplify the complex Kubernetes ecosystem, akin to a guide helping an architect navigate through a labyrinth of construction blueprints, materials, and tools. For more advanced methods, background, tips, and tricks, dive into the rest of the article.

For more information on all things Kubernetes, Docker, and containerization, check out our Ultimate Kubernetes Tutorial.

Preparing Your Toolkit: Essential Tools and Prerequisites

Before we start building our ‘house’, let’s ensure we have all our construction materials and tools at hand. After all, an architect is only as good as his tools, right? So, what exactly are the prerequisites for constructing our Kubernetes ‘house’ and its associated features?

Linux serverFoundation of the house
DNSAddress book of the internet
UbuntuUser-friendly, large community, compatible with most software
Server namesProvide unique identity to each server
Control planeMakes important decisions like scheduling and responding to cluster events

Firstly, you’ll need a Linux server. This is the foundation of our house. It’s where you’ll install Kubernetes and all the other essential tools. But why Linux, you ask? Well, Linux servers are known for their stability, security, and flexibility, making them the ideal foundation for our Kubernetes ‘house’.

Next on the list is DNS. The Domain Name System (DNS) is a crucial part of the setup process. It’s like the address book of the internet, translating user-friendly domain names into IP addresses that machines understand. Without DNS, your Kubernetes setup would be like a house without a proper address – functional, but hard to locate.

Now, let’s discuss the choice of Ubuntu for the setup. Ubuntu is a popular choice for many reasons. It’s user-friendly, has a large community for support, and most importantly, it’s compatible with most software. The significance of server names is also crucial. They provide a unique identity to each server, making it easier to manage and locate them in a network, much like the unique addresses for houses.

Finally, let’s touch upon the control plane. In the Kubernetes setup, the control plane is like the architect of the operation. It makes all the important decisions, like scheduling and responding to cluster events. Choosing the right control plane is vital for the smooth construction of your Kubernetes ‘house’.

In the following sections, we’ll delve deeper into each of these aspects and provide you with a step-by-step guide to constructing your Kubernetes ‘house’ with Rancher. Let’s put on our hard hats and get to work!

Laying the Foundation: Installing RKE2

With our toolkit ready, it’s time to lay the foundation of our ‘house’. Our first task? Installing RKE2 on our server. Let’s break down the process step-by-step, like following a construction blueprint.

  1. First, download the RKE2 binary from the official GitHub repository. You can do this using the wget command in your terminal, similar to ordering your construction materials.

Example of downloading the RKE2 binary:

wget <RKE2 binary URL>
  1. Once the binary is downloaded, make it executable using the chmod command. This allows the binary to be run as a program, much like preparing your materials for use.

Example of making the binary executable:

chmod +x <RKE2 binary>
  1. Next, move the binary to the /usr/local/bin directory. This directory is included in the PATH environment variable, which means you can run the program from any location. It’s akin to having your materials ready at the construction site.

Example of moving the binary to the /usr/local/bin directory:

mv <RKE2 binary> /usr/local/bin/
  1. Finally, start the RKE2 server. You can do this by running the rke2 server command in your terminal. This is the equivalent of starting the construction work.

Example of starting the RKE2 server:

rke2 server

Now that we’ve laid the foundation with the RKE2 server, it’s important to inspect the foundation. This is where kubectl comes into play. Kubectl is a command-line tool that allows you to control Kubernetes clusters. You can use kubectl to verify that your RKE2 server is running correctly, much like a site inspector checking the foundation.

Installing RKE2 Agent

Next up, we need to install the RKE2 agent. The agent is responsible for running your workloads and communicating with the server, like the workers at a construction site. The process for installing the agent is similar to the server installation. However, instead of running the rke2 server command, you’ll run the rke2 agent command.

You would need to follow the instructions for downloading RKE2 and moving it to your path, for instance:

# Download RKE2
curl -sfL | sh - 

# Move to location in the PATH
sudo mv rke2 /usr/local/bin/

# Create symlinks for 'kubectl', 'crictl', 'ctr', etc.
sudo ln -s /usr/local/bin/rke2 /usr/local/bin/kubectl
sudo ln -s /usr/local/bin/rke2 /usr/local/bin/crictl
sudo ln -s /usr/local/bin/rke2 /usr/local/bin/ctr

Then to start the agent, you could use:

sudo systemctl start rke2-agent.service

Remember you need to replace all the dummy values with your real values.
For instance, you might want to first issue this:

export SERVER_URL=<url to the RKE2 server>
export TOKEN=<token>

Then start your rke2 agent using these environment variables.

sudo rke2 agent --server $SERVER_URL --token $TOKEN

Please note, starting the agent might require specific configuration and token that must be given by your server. And you should install curl first if it’s not existing yet in your OS.

In RKE2, Tokens act as a form of authentication between the server and the agent, akin to workers checking in at the construction site. When an agent connects to a server, it presents the token, and if the token is valid, the server allows the connection.

The installation of RKE2 involves several key steps and components, just like laying the foundation of a house. Understanding these elements is crucial for a successful and secure Kubernetes setup, much like understanding the blueprint is crucial for building a house.

Building with Rancher: The Star of the Show

Having laid the groundwork with RKE2, akin to preparing the site and laying the foundation of our ‘house’, it’s time to introduce the star of the show – Rancher. Imagine Rancher as a multi-functional construction tool that’s revolutionizing how we build. Rancher is a complete software stack for teams adopting containers. It addresses the operational and security challenges of managing multiple Kubernetes ‘houses’, while providing DevOps teams with integrated tools for running containerized workloads.

To kick things off, we’ll install Rancher using Helm, a package manager for Kubernetes.

Example of installing Rancher using Helm:

helm install rancher <Rancher chart URL>

Think of Helm as the delivery service that brings our construction tool, Rancher, to our site. Helm charts help you define, install, and upgrade even the most complex Kubernetes application. Rancher, when installed with Helm, provides a robust and flexible platform for managing all aspects of your Kubernetes constructions.

Once Rancher is installed, the next step is setting up the Rancher GUI. The GUI, or Graphical User Interface, is a user-friendly platform that allows you to manage your ‘houses’ visually. This is a game-changer as it simplifies the complex process of managing multiple constructions.

Speaking of multiple constructions, let’s talk about Rancher’s multi-cluster design. This design allows you to manage all your ‘houses’ from a single pane of glass. Whether you have one ‘house’ or a hundred, Rancher gives you the ability to manage them all seamlessly, like a master architect overseeing multiple projects.

To gain initial access to Rancher, you’ll need to retrieve a bootstrap password through the command line. This password is like the master key to your construction site, so keep it safe!

One of the standout features of Rancher is the control it offers. It allows you to provision a Linux host, assign roles to nodes, and even create a custom Kubernetes ‘house’. This level of flexibility and control is unparalleled and is one of the reasons why Rancher is a favorite among DevOps teams, much like a versatile construction tool is favored by architects.

For this setup, we’ll be using a single cluster deployment. This choice simplifies the setup process, making it more manageable and less prone to errors, like choosing to build a single-storey house to minimize complexity.

Rancher’s adaptability and integration capabilities are truly remarkable. It allows you to create and manage its server within a Docker container, simplifying the deployment process, much like an innovative construction method that eases the building process. This unique feature sets Rancher apart and makes it a valuable tool in any Kubernetes ‘house’ construction.

Adding the Final Touches: Installing Longhorn

With the foundation (RKE2) and the structure (Rancher) in place, we’re ready to add the final touches to our ‘house’ – Longhorn. Imagine Longhorn as the interior designer of our Kubernetes ‘house’, providing a lightweight, reliable, and powerful distributed block storage system. It’s designed to integrate natively with Kubernetes, much like an interior designer who understands the architecture of the house.

Installing Longhorn is a straightforward process with Helm, our trusted delivery service.

Example of installing Longhorn using Helm:

helm install longhorn <Longhorn chart URL>

Just like we used Helm to bring Rancher to our site, we’ll use it again to bring Longhorn. Helm’s package managing capabilities make it easy to install and manage applications on Kubernetes clusters, like a delivery service that not only brings the materials but also assists in their installation.

Once Longhorn is installed, you can access the Longhorn GUI through Rancher. The GUI provides a visual representation of your storage and volume configurations, making it easier to manage and monitor your storage resources, much like an interior designer’s blueprint.

One of the key concepts to understand when working with Longhorn is storage classes. In Kubernetes, a StorageClass provides a way for administrators to describe the “classes” of storage they offer. When a volume is provisioned in Kubernetes, it is done so with a particular storage class, like choosing a specific type of decor for each room.

One of the standout features of Longhorn is the automatic creation of Physical Volumes (PVs) based on a Physical Volume Claim (PVC). In simple terms, a PVC is a request for storage by a user, while a PV is a piece of storage in the cluster. Longhorn automatically creates a PV in response to a PVC, simplifying the storage management process, like an interior designer automatically choosing decor based on the homeowner’s preferences.

The integration of RKE2 and Longhorn is a match made in heaven. The security-focused nature of RKE2 combined with the lightweight and reliable storage provided by Longhorn creates a robust and efficient Kubernetes environment, much like a well-constructed house with an impressive interior design.

Wrapping Up: The Completed ‘House’

And there you have it! We’ve journeyed through the complexities of the Kubernetes ecosystem, akin to navigating through a complex architectural blueprint, and emerged on the other side with a comprehensive, robust, and efficient ‘house’. Let’s take a moment to recap what we’ve accomplished in our construction journey.

We started with the essential tools and prerequisites, setting up a Linux server, much like preparing the construction site, and understanding the crucial role of DNS, akin to having a proper address for our ‘house’. We then moved on to the installation of RKE2, laying the foundation of our ‘house’, diving into the importance of tokens, ensuring secure communication within our construction site.

The star of our show, Rancher, was next. We installed Rancher using Helm, our trusted delivery service, set up the Rancher GUI, our user-friendly control panel, and explored its multi-cluster design, akin to managing multiple construction projects. We also delved into the flexibility and control Rancher offers, from provisioning a Linux host to creating a custom Kubernetes ‘house’, showcasing the versatility of our construction tool.

Finally, we installed Longhorn, akin to adding the final touches to our ‘house’. We discussed the role of storage classes, like choosing specific decor for each room, and the automatic creation of Physical Volumes (PVs) based on a Physical Volume Claim (PVC), simplifying the storage management process like an interior designer automatically choosing decor based on the homeowner’s preferences.

The benefits of this setup are numerous. From the security-focused nature of RKE2 to the lightweight and reliable storage provided by Longhorn, this setup offers a robust and efficient Kubernetes ‘house’. But the real game-changer is Rancher. With its unique features and capabilities, Rancher simplifies the complex process of managing multiple ‘houses’, making it a valuable tool in any Kubernetes ‘construction’ journey.

So, whether you’re a seasoned architect (DevOps professional) or just starting your construction (Kubernetes) journey, this guide provides a practical and comprehensive approach to building your Kubernetes ‘house’ with essential tools. Happy building!