Working with Microservices-7: Creating a cluster for microservices application by using Rancher

In this article, we will create a cluster by using Rancher in order to deploy the microservices application it using Helm in the Jenkins pipeline.

Cumhur Akkaya
8 min readJul 28, 2023

We will make the necessary settings in Rancher to run the Springboot web application consisting of 10 microservices in this cluster. We will create a “node template” for the cluster, then introduce the credentials required for the Rancher to access AWS resources, then assign credentials to the node template, and examine the structure of the cluster. We will do it all step by step.

Topics we will cover:

1. Creating AWS cloud credentials

2. Creating a Node template and assigning the credentials to the Node template

3. Creating a cluster consisting of 3 nodes using the Rancher “cluster management” menu

4. Examining the structure of the cluster

5. Creating Namespace

6. As a result

7. Next post

8. References

If you like the article, I will be happy if you click on the Medium Following button to encourage me to write more, and not miss future articles.

Share this article with friends in your network and help others to upskill.

Your clapping 👏, following, or subscribing helps my articles to reach a broader audience. Thank you in advance for them.

Prerequisite:

Your Rancher server must be installed and configured. If your Rancher server is not installed, you can install it step by step from my article below;

1. Creating AWS cloud credentials

We will create cloud credentials. So, we will allow Rancher to access and use our AWS resources. For this, we will create our Secret and Access keys in the Cloud credential menu. (1) In the left navigation pane, choose “Cloud credential”, then click on the “Create” button, as shown in Figure 1.

Figure 1.

Choose AWS, as shown in Figure 2.

Figure 2.

The access key and secret key appear, enter name and description then choose the region that you use, and click on the create button, as shown in Figure 3.

Figure 3.

The credential we will use in “Node Template” appears, as shown in Figure 4.

Figure 4.

2. Creating a Node template and assigning the credentials to the Node template

Choose “node templates” in the Cluster Management menu, and click on the “Add template” button, as shown in Figure 5. (2)

Figure 5.

We chose Amazon EC2 because we will create a cluster on Amazon EC2, as shown in Figure 6.

Figure 6.

We choose the region where we will work and the credential we created above in Cloud credential box, and click on the “Next” button, as shown in Figure 7.

Figure 7.

We choose the Availability zone and VPC where we will work, and click on the “Next” button, as shown in Figure 8.

Figure 8.

As Security Best practice, it is more convenient for us to create a Security Group ourselves and select it in the “Choose one or more existing groups” menu, but now we will choose “Standart: Automatically create rancher-nodes group”. So, the Security group will be created by the rancher.

Then click on the “Next” button, as shown in Figure 9.

Figure 9.

Enter the following values in the Instance section, as shown in Figure 11.

Region            : us-east-1
Security group : create new sg (rancher-nodes)
Instance Type : t3a.medium
Root Disk Size : 16 GB
AMI (RancherOS) : ami-02fe87f853d560d52
SSH User : rancher
Label : os=rancheros

As AMI, we used Ubuntu’s Rancher AMI. You can go to EC2>AMI Catolog page for the updated AMI name, as shown in Figure 10.

Figure 10.

This AMI is a rancher-specific AMI and contains a “rancher” user, not “ubuntu”. It is important to enter the User name as “rancher”, because we will be connecting to Rancher via SSH, as shown in Figure 11.

Figure 11.

We have completed the node template creation process, and the node template appeared below, as shown in Figure 12.

Figure 12.

3. Creating a cluster consisting of 3 nodes using the Rancher “cluster management” menu

In order to create a cluster, choose the “cluster management” menu, as shown in Figure 13.

Figure 13.

In the left navigation pane, choose “Cluster”, then click on the “Create” button. If we had an existing cluster, we could include it in Rancher by clicking the “Import Existing” button, as shown in Figure 14.

Figure 14.

Choose Amazon EC2, because we will create the cluster on Amazon EC2. Don’t forget to choose RKE1 since we will use the RKE1 version, as shown in Figure 15.

Figure 15.

Enter Cluster nameand description , as shown in Figure 16. Then enter ;

Names prefix: The value we will enter here will be the name of the EC2 instances that will occur. I entered microservice-node-. Put a hyphen at the end, because it will name the EC2 instances that will occur as microservice-node-2, microservice-node-2, microservice-node-3.

Template: Choose the template that we created above,

Count: This is the number of EC2 instances that will be created.

Leave other settings as default, and click on the create button.

Figure 16.

The cluster started to be created, this will take a few minutes, as shown in Figures 17–18.

Figure 17.

Cluster installation is finished, as shown in Figure 18.

Figure 18.

We clicked on “microservice-app-cluster”, and we saw that 3 nodes are active, as shown in Figure 19.

Figure 19.

4. Examining the structure of the cluster

We look at the information of the cluster from the hamburger menu, and select the name of the created cluster, as shown in Figure 20. (3)

Figure 20.

The resources used are displayed in the Cluster Dashboard, as shown in Figure 21.

Figure 21

The information of the 3 Nodes created appears in the Nodes section, as shown in Figure 22.

Figure 22.

There are no Pods right now because we haven’t installed our app to cluster yet, as shown in Figure 23.

Figure 23.

In addition, we saw that our nodes were created with the name we gave in the EC2>Instances menu, as shown in Figure 24.

Figure 24.

Follow the instructions in the link to solve possible faults that may occur in the cluster. (4)

5. Creating Namespace

Finally, we will create a namespace for our cluster, select the name of the created cluster in the hamburger menu, as shown in Figure 25.

Figure 25.

Click on “Projects/Namespaces”, then “Create Namespaces”, as shown in Figure 26.

Figure 26.

Write “petclinic-staging-ns” in the “Name”box, then leave the other settings as default and click on the create button. If we want, we can limit the CPU, memory of the namespace here, as shown in Figure 27.

Figure 27.

“petclinic-staging-ns” namespace is created, as shown in Figure 28.

Figure 28.

Our cluster where we will install the application is now ready.

6. As a result

We successfully created a cluster by using Rancher in order to deploy the microservices application. We made the necessary settings in Rancher to run the microservices application in this cluster. We created a “node template” for the cluster, then introduced the credentials required for the Rancher to access AWS resources, then assigned credentials to the node template, and examined the structure of the cluster.

As you can see, Rancher makes it very easy to create clusters in Kubernetes.

You can find the necessary files in my GitHub repo.

Share this article with friends in your network and help others to upskill.

If you liked the article, I would be happy if you clicked on the clap 👏 button and the Medium Following button to encourage me to write and not miss future articles.

Your clapping, following, or subscribing helps my articles to reach a broader audience. Thank you in advance for them.

For more info and questions, don’t hesitate to get in touch with me on Linkedin or Medium.

7. Next post

In the next article, Working with Microservices-8: Preparing the staging pipeline in Jenkins, and deploying the microservices app to the cluster with Helm in Figure 29.

We will prepare the staging pipeline in Jenkins, and deploy the Java-based Springboot web application consisting of 10 microservices to the cluster with Helm. We will prepare script files to run in the Jenkins pipeline, and then we will do packaging, deploying, pushing and tagging with them. We will create Rancher API Key to access the “Rancher” from the Jenkins pipeline. We will prepare Jenkinsfile and Jenkins Staging pipeline. Finally, we will be able to deploy the microservices app on the Kubernetes cluster by running a single helm install command in the Jenkins CI/CD pipeline.

We will do it all step by step.

Figure 29 -Working with Microservices-8: Preparing the staging pipeline in Jenkins, and deploying the microservices app to the cluster with Helm

Happy Clouding…

I frequently share articles about Cloud and DevOps. Don’t forget to follow my LinkedIn or Medium account to be informed about new articles.

--

--

Cumhur Akkaya

✦ DevOps/Cloud Engineer, ✦ Believes in learning by doing, ✦ Dedication To Lifelong Learning, ✦ Tea and Coffee Drinker. ✦ Linkedin: linkedin.com/in/cumhurakkaya