Are You Eligible for PMP Certification?

Though there are numerous academic qualifications and certifications that can improve your chances of getting a better job and higher pay, knowing about the qualifications to be eligible for the…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Set Up Rancher 2.6 Lab Environment in a Ubuntu VM on Cloud or Your Computer

Kubernetes provides a lot of features from orchestrating your nodes about managing containers to scaling applications while load balancing and monitoring their health. When it is about setting up a Kubernetes cluster and publishing your containers to the cluster, you have a number of different methods for each. Rancher is one of these methods that makes it possible to set up a cluster using RKE (Rancher Kubernetes Engine) and manage clusters (even existing ones created with other installation methods) as well as your applications. In this post, we will discuss how to set up a lab environment which consists of Rancher, making it reachable outside the VM, creating and managing clusters with Rancher, k3s, and lxd.

If you are not working as root user, give your user access to Docker socket:

Afterwards you have to logout and login again.

Install lxd to run containers with init system and we’ll be able to use Rancher to create cluster for us on them.

There will be 2 different installation alternatives and which one should be used is depending on your VM placement. Before diving into them, let’s see what nip.io is, what it provides, and why/when to use it.

In order to make our Rancher installation easily reachable from different locations and generate certificates about its domain, we will use DNS records for a domain. If you don’t have a domain, nip.io is an open source software and also usable as a free service to use as DNS records for our projects. Just use your ip address (for example 10.20.30.40 in your LAN) and all DNS requests to these addresses will be resolved to 10.20.30.40 :

So even if it is a private IP address, we can use the DNS records as FQDNs on our configuration files. When we have a public IP address, we can use this address in the above format to get certificates and reach our installation.

If you are working in a VM on your computer, there may be no public access and in this case & post combination, we will utilize self-signed TLS certificates which are automatically created by Rancher.

It will install Rancher in a Docker container and make it reachable over ports 80 and 443. Since the certificate is self-signed. You can use your URL with nip.io or IP address to reach Rancher.

When you deploy your VM on a cloud provider, or by giving an existing public IP address in your on-prem environment, just add A record to your DNS server or use nip.io address like explained above. It will create certificates and make them signed by Let’s Encrypt. Then, deploy Rancher:

Rancher will be up and running in a couple of minutes. Then you will be able to connect to your domain and reach its Web UI.

First time Rancher is installed, it will ask for a predefined password. Before continuing, we should get the password from our installation. In that way, people who may connect to Rancher’s Web UI before us cannot access to Rancher without this password. We can get it via:

Get the password from the output and login to the Rancher’s Web UI. A UI like this should be seen on the screen:

Rancher 2.6 Welcome Screen

We need some nodes in our VM to create a Kubernetes cluster with Rancher. Rancher 2.6 supports both RKE and K3s installation methods(beware of tech previews in UI).

We’ll use LXD to create nodes as Linux containers. These containers will include an init system by default so that Rancher’s agent which requires it can utilize it to set up our cluster components.

Firstly, init LXD in automatic mode:

In this post, I will create 6 nodes. 3 of them will be used for control plane while the other 3 will be made worker nodes.

Create nodes with lxd:

In the default configuration, it is not possible to create containers in these containers. So we should enable nested containers:

The last thing is creating an empty /dev/kmsg file in each machine as a workaround, because K3s will fail to start if it cannot find this file:

Now it is time to use our Rancher installation to set up a new cluster on our nodes. Even if they are in the same lab machine, we try to make them behave like they are working on different locations so that we can simulate different scenarios in this environment.

On Rancher’s dashboard page, click Create button:

There is a switch on the right, which allows us to change version between RKE1 and RKE2/K3s. In this post, since we are setting up a lab environment and want to experience some different options, we will continue with RKE2/K3s option, which adds Tech Preview to some options:

We will use “Use existing nodes and create a cluster using RKE2/K3s (Tech Preview)” and click Custom:

We’ll give a name to our cluster and select K3s from Kubernetes Version box:

If you want to inspect or change configuration options from the menus, it may be great time to make that. Afterwards, click Create to define a new cluster in Rancher. You should be in Registration tab:

For example:

Go to Machines tab in Rancher and wait for your control plane nodes to be in Running state:

Afterwards, go back to the Registration tab. Next, uncheck etcd and Control Plane, and check Worker on Rancher’s UI:

Copy the command in Step 2 and now, we will use the command on worker nodes to make them joined to our newly set up cluster:

Example:

Wait for worker nodes to be available. And your cluster is ready!

Rancher’s cluster node listing screen with a cluster that is provisioned with K3s

Add a comment

Related posts:

Is a Time Zone Difference Really a Problem?

An engineer hits a roadblock. Two possible solutions, two different outcomes — and neither one is exactly what you, the client, want. The engineer is confused. He needs to talk to you. Now. But the…

Delivering an Outstanding Open Banking Experience

Open Banking security is important. But so is delivering an outstanding customer, developer, and operations experience. What does this mean for Open Banking in Canada…

Digital Transformation Consulting Solutions

During unprecedented times, how an organization achieves efficiency, customer satisfaction, and lowers business costs are critical factors in whether or not a business will survive. Most…