Devtron : Deploy your applications over k3s, Lightweight Kubernetes, in no-time
Tags: kubernetes, opensource, showdev, devops
Published: 2021-09-09 15:41:02

In this blog, we will set up Devtron over [k3s - Lightweight Kubernetes](https://k3s.io/). If you haven't heard about Devtron yet, let's take a moment to walk you through it. Devtron is an open-source AppOps solution that caters and supports end-to-end software delivery workflow for Kubernetes, written in Go. It can be used for the deployment of your applications over Kubernetes through simple configurations over user-intuitive UI.
{% github devtron-labs/devtron no-readme %}
## Why k3s?
Devtron is cloud-agnostic and can easily be installed over the k3s cluster. Let’s understand about k3s - Lightweight Kubernetes, shall we? It is essentially a lightweight version of Kubernetes that can be installed in a binary less than 100MB. It can be installed as a single-node as well as multi-node cluster and is fully compatible and production-ready Kubernetes distribution.
Some of the advantages of having k3s cluster are -
* Less System Resources
* Quick Cluster Setup
* Easy to add Worker Nodes (k3s-agent)
* Lightweight
* All features as that of k8s

{% link https://dev.to/abhinavd26/all-about-k3s-lightweight-kubernetes-3ell %}

## K3s Cluster Setup
Before we get started and install Devtron, we need to set up the k3s cluster in our servers. We will be setting up a single node cluster. Please execute the following commands to set up the single-node k3s cluster for Devtron.

The only thing we need to do is set up the k3s server/master node where the necessary configuration files will be installed. The command below downloads and sets up the master node in the server with an extra flag for setting up the right permission of the KubeConfig file.

```bash
curl -sfL https://get.k3s.io | sh -s - --write-kubeconfig-mode 644
```

Please note that the below command is not mandatory for setting up the k3s cluster, but for Devtron installation, we need to deploy the local-path-storage as it will create hostPath to dynamically provision Persistent Volume (PV) based on Persistent Volume Claim (PVC) for Devtron installation.

```bash
kubectl apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/deploy/local-path-storage.yaml
```

Congratulations! You have successfully set up the k3s cluster. To verify the nodes, please execute the command - `kubectl get nodes`, it will result in the nodes which are created. For the single cluster setup, you will find only one node as  `control-plane,master`.

[Note: You need to deploy all the commands in the same cluster where the master is being installed]

## System Configurations for Devtron Installation
* 2 CPUs+ cores
* 4GB+ of free memory
* 20GB+ free disk space

## Devtron Installation
After the cluster is successfully set up, we are ready to go with the Devtron installation over it. Installing Devtron is quite a straightforward process with just a few commands. It can be installed using [helm3](https://docs.devtron.ai/setup/install/install-devtron-helm-3), [helm2](https://docs.devtron.ai/setup/install/install-devtron-helm-2), and [kubectl](https://docs.devtron.ai/setup/install/install-devtron-using-kubectl). For this particular demonstration, we will be using helm3. If you haven’t installed helm3 in your k3s cluster, please follow along -

### Helm3 Setup
Before moving ahead, let’s set up helm3 in our cluster. The helm3 can be installed in the traditional way. Please follow the commands for installation -
The below command will download the helm3 installation script on our server.
```bash
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
```
Making the script executable so that we can run the helm3 installation script.
```bash
chmod 700 get_helm.sh
```
The command below will execute the installation script and download helm3 on our server.

```bash
./get_helm.sh
```
To make the helm interact with the k3s master, we need to set up the path of the KUBECONFIG file. Please execute the following command -
```bash
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
```

For detailed information about the KUBECONFIG file in the k3s cluster, please refer to this [documentation](https://rancher.com/docs/k3s/latest/en/cluster-access/).

### Devtron Installation
Now, as we have successfully set up our cluster for Devtron Installation, please execute the following commands, and let’s complete the Devtron installation with just a few simple commands -
The command below will add Devtron repo in helm known repositories
```bash
helm repo add devtron https://helm.devtron.ai
```

The below command will install Devtron in the provided namespace, i.e., devtroncd. The install command initiates Devtron-operator, which spins up all the Devtron micro-services one by one in about 15-20 mins.
```bash
helm install devtron devtron/devtron-operator --create-namespace --namespace devtroncd
```
To check the status of the installation, please execute the following command. If the installation is still in progress, it will print `Downloaded`. And when the installation is complete, it prints `Applied`.
```bash
kubectl -n devtroncd get installers installer-devtron -o jsonpath='{.status.sync.status}'
```
After the installation, we need to access the Devtron dashboard with the right credentials. For this blog, we will be using the concept of NodePort as service type to access the dashboard. Please execute the following command and edit the type from LoadBalancer to NodePort.
```bash
kubectl edit svc devtron-service -n devtroncd
```
The command will open the editor for you. Press `i` for insert mode, change type from `LoadBalancer` to `NodePort` and then enter `:wq` to save and exit the editor mode.

To verify that the changes have been made, please execute the following command. It will give all the services running with their port number. For Devtron-service, please note down the port number given. It will be used for accessing the dashboard.
```bash
kubectl get svc -n devtroncd
```
After changing the type to `NodePort`, we are now ready to access the dashboard. To do so, type the IP of the server with the port number given for `devtron-service`. 

[**Note :** The `NodePort` port must be added in the security group of your instance.] 

In my case I am using AWS so here's how you can add the NodePort number or range in the security group of your instance.

**Step-1 :** Check the instance, click on security group under the the security tab, as shown below.

![security-group](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z5vdbjfa4preei3jbaew.png)

**Step-2 :** Click on the `edit inbound rules` as shown in the image below.

![inbound-rules](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8su4az2z6yq9s7muvh7y.png)

**Step-3 :** Now you need to add rules as per your requirement. In our case, we need to add a rule of type `Custom TCP` and then enter the range of `NodePort` or specific `NodePort` port which you got for `devtron-service` and then click on `Save-rules`. Also for security reasons you can add the source as per your requirement. 0.0.0.0/0 is for anywhere, means it can be accessed by anyone from any IP.

![rule-add](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dmrokkuhdd892q4533cf.png)

Now we would be able to access the dashboard with `IP:NodePort-Port/dashboard`. For admin credentials, the username is `admin` , and for password, run the below command.
```bash
kubectl -n devtroncd get secret devtron-secret -o jsonpath='{.data.ACD_PASSWORD}' | base64 -d
```
Kudos! We have successfully installed Devtron in our single node k3s cluster and accessed the dashboard. For any doubts, feel free to comment down or read the [official documentation](https://docs.devtron.ai/) of Devtron.

## What Next?
Now that we have configured the k3s cluster and successfully installed Devtron over it, we are ready to begin our first [app creation](https://docs.devtron.ai/user-guide/creating-application) and deployment through Devtron. The Application Deployment process needs a dedicated blog by itself. Feel free to check out our documentation for a detailed understanding of [App Deployment](https://docs.devtron.ai/setup/start-using) along with the [Configuration](https://docs.devtron.ai/user-guide/global-configurations) of Devtron after installation. You can also have a look at this video for detailed understanding of Devtron's features.

{% youtube FB5BI3Ef7uw %}