Kubernetes deployment using Rancher
Rancher is open-source software for managing Kubernetes clusters and the applications running in it.

Rancher is an open-source platform where you can create the cluster or import an existing cluster. Today I will tell you how to setup Rancher and add an existing Kubernetes cluster into Rancher. We will cover how applications can be deployed to Kubernetes clusters using Rancher.

Rancher Homebase is [here](https://rancher.com/)

Pre-requisites

Linux VM (centos for this demo)

Kubernetes cluster

Prerequisites that need to be available on the VM

Docker

Docker-compose

Open Ports 80 & 443 on the VM

SSL Certificates and private key in pem format

Valid DNS name

Steps to run rancher on the VM

Copy server.pem & private.pem SSL certificate to home/centos/certificates location in VM

SSL certificate to location in VM Create a directory named /data on the vm

on the vm Clone the repo https://github.com/rancher-docker-compose

[centos@localhost ~]$ docker-compose up

With that, Rancher is up and running.

Setting up Rancher

Login to Rancher URL (DNS name) that you set up for the IP of VM and set password, URL to use.

Provide the DNS name in the URL

Add Kubernetes cluster to Rancher

Click on add cluster > Import existing cluster

Provide cluster name and click on create

Copy and apply the kubectl command that you see on the kubernetes cluster and click done

Once it is applied successfully the cluster will be listed in Rancher with active status

If you click on the Cluster name you will be able to see the cluster specs

Cluster is added to rancher successfully and now we are ready for deployment!

Gearing up for Deployment

Click the cluster name that you added and navigate to Projects/Namespaces .

. Click on Add Project

Give the project name that you wish and then click Create.

Click Add Namespace below Project: (the project that you added),

In the below example the namespaces added are engine, trainer, logging, nginx-ingress-controller and the project name is omnius

To add Docker Secrets , complete the following steps:

Click the cluster that you added and navigate to Project/Namespaces and then click Project: omnius. (the name that you provided) Click Resources and select Secrets from the drop-down list. Click on Registry credentials

4. Add Registry

Add the details here select the namespace you wish to add the secrets or select Available to all namespaces in this project if you wish to add to all namespaces. Click Save.

Note: Also the name dockerregcred will depends on the name that you provided in the yaml file of your application.

Add catalog

Catalogs are GitHub repositories or Helm Chart repositories filled with applications that are ready-made for deployment. Applications are bundled in objects called Helm charts.

To add catalog, complete the following steps:

Click the cluster that you added and navigate to Project/Namespaces and then click Project: <project name>. Click Tools and select Catalogs from the drop-down list. Click Add Catalog. (add details of your Helm repo)

4. Click save

Click the cluster that you added and navigate to Project/Namespaces and then click Project: <project name>. Click Tools and select Catalogs from the drop-down list. Click Apps on the main menu and then click Launch.

The Catalog page appears with the list of helm chats as icons, Example of the catalog i added (platform-release):

ELK helm chart will be like as below, This chart should be present in your harbor repository that you added in the catalog in previous step.

ingress file in template folder and we overwrite (ingress.hostName)the values while deploying using Rancher, We use question.yaml for this.

We can provide a default value in question.yaml and change it during deployment.

Deploying application:

Click on elk-fluentbit and you will see the following fields populated.

If required provide another value instead of example.abc.com and click Launch, also you can change the namespace if required.

Click Resources and select Workloads from the drop-down list and Verify the status of pods and ensure that the pods are active.

Monitoring : You can enable prometheus and grafana monitoring using the rancher dashboard.

Select the cluster you want to enable monitoring for. > Tools > monitoring > set the limits > Click on enable

That’s it.

Hope you enjoyed it. In case you have questions, feel free to reach out to devops@omnius.com.
['Eldhose P Wilson']
['Deployment', 'Rancher', 'Kubernetes', 'DevOps', 'Containers']