DEV Community

Cover image for Local Kubernetes development made easy with Minikube - Devtron
Arushi shukla
Arushi shukla

Posted on

Local Kubernetes development made easy with Minikube - Devtron

Devtron being an open source platform appreciates the contributions coming from the community all across the globe. Everyday, the team of Devtron is leveraging the idea of building the platform more developer-friendly. To contribute and provide your ideas we came up with a solution to let our contributors know how the process will work.
Frequently installing devtron to check your applied changes can be a tedious task and will not give a speedy development. Try out this hassle-free setup to locally set up devtron.

Before starting up with the setup lets first understand, What Devtron is?

GitHub logo devtron-labs / devtron

Software Delivery Workflow For Kubernetes

Devtron is an open source software delivery workflow for Kubernetes written in Go. It is known for its slick user interface which allows developers to deploy their Microservices over Kubernetes in no-time. Not only application deployment, but also it helps in monitoring and logging just through the Devtron dashboard itself. Moreover it allows developers to integrate their existing open-source systems like ArgoCD, Jenkins, Clair, and others.

Starting with the setup few prerequisites are to be taken into consideration which are listed below.

Prerequisites -

  • Docker installed
  • Kubernetes installed
  • Having a basic architectural knowledge about devtron and a local Kubernetes cluster is a prerequisite for this setup.

In my case, I took a single node Minikube cluster. You can choose any as per your requirement.

Minikube Setup

What is minikube?

Minikube is a utility to run Kubernetes on your local machine. It creates a VM on your local machine and deploys a simple cluster containing only one node.
To set up a Minikube cluster , you first need to install Minikube using this documentation. After the successful installation of Minikube , now it’s time to create a cluster.
Cluster creation in Minikube is quite simple using a single command.

minikube start --cpus 3 --memory 7168
Enter fullscreen mode Exit fullscreen mode

Let the command completely run, and create a cluster. The CPU and memory requirements are given explicitly because by only running minikube start a cluster is created with the default configurations of 2 CPUs and 2048 memory which is insufficient for devtron installation.
Afterwards, run the below command to check the health of the nodes.

kubectl get nodes
Enter fullscreen mode Exit fullscreen mode

Now, let's start installing Devtron!!

Devtron Installation

Installation of Devtron can be done using multiple command line programs. Eg - helm3, helm2 and kubectl. Among these, helm3 is the recommended one. Before that, refer to the following documentation to install helm.

STEP 1: To install devtron using helm3 run the following commands -

helm repo add devtron https://helm.devtron.ai
helm install devtron devtron/devtron-operator --create-namespace --namespace devtroncd
Enter fullscreen mode Exit fullscreen mode

The installation time will be dependent on the internet speed on your local machine. Generally the installation takes upto 20-25 mins.

STEP 2: Keep on executing the command below to check the status of the installation. If it is still in progress it will show Downloaded and once finished it will show Applied.

kubectl -n devtroncd get installers installer-devtron -o jsonpath='{.status.sync.status}'
Enter fullscreen mode Exit fullscreen mode

You can also run the following command to keep track of your pods.

kubectl -n devtroncd get pods - w 
Enter fullscreen mode Exit fullscreen mode

STEP 3: After the successful installation of devtron, now we are ready to access the dashboard. As the cluster is locally created it will accessible on localhost or localhost IP - 127.0.0.1
Use the below command to access the dashboard locally

minikube -n devtroncd svc/devtron-service
Enter fullscreen mode Exit fullscreen mode

You can also use minikube tunnel to create an EXTERNAL IP to access the dashboard, or port-forwarding the devtron-service will also work.

STEP 4: Logging into the dashboard using admin access will require a password which will be generated from the below command.

kubectl -n devtroncd get secret devtron-secret -o jsonpath='{.data.ACD_PASSWORD}' | base64 -d
Enter fullscreen mode Exit fullscreen mode

Hurray..! Your devtron installation is successfully done.To know more about installation refer to official site of Devtron.

Starting the Local Setup

As we move forward, devtron installation was the first step we successfully completed. We are ready to set up our local development environment for Devtron and play around with it. For building any features or fixing bugs, we need to have the source code of the project at the very first place.
[Note: Please make sure that the wire module is installed in your system]

Follow the steps below for the setup -

STEP 1: Clone the project
The below command will clone the devtron repo in your system. If you haven’t installed git, install it from here.

git clone https://github.com/devtron-labs/devtron.git
Enter fullscreen mode Exit fullscreen mode

STEP 2: Build the project.
Go to the devtron directory which you cloned, using the command cd devtron and build the devtron source code by the following command.
make build

STEP 3: Port Forwarding the Services
Now we need to port forward a few services to establish a connection between Devtron running with the binary we will execute in the next step. Execute the following commands in different terminals which can help you to check the logs and debug if any connection issues occur and also do not close the terminal or stop these commands until the work is done. If any commands are stopped, then please execute it again to maintain the connection with local setup.

kubectl -n devtroncd port-forward svc/argocd-server 8000:80

kubectl -n devtroncd port-forward svc/argocd-dex-server 5556:5556

kubectl -n devtroncd port-forward svc/postgresql-postgresql 5432:5432

kubectl -n devtroncd port-forward svc/devtron-nats 4222:4222
Enter fullscreen mode Exit fullscreen mode

STEP 4: Setting up Environment Variables and executing Binary

Now we need to set up a few environment variables to connect the source code with the Devtron which we installed initially. Please run the following commands from the root directory where you build the project. It will setup the environment variable and execute the binary as well. Do not stop the command until the work is not done.
[Note: python3 must be installed in the system]

wget https://raw.githubusercontent.com/devtron-labs/devtron/main/developers-guide/scripts/exporter.py
python3 exporter.py
Enter fullscreen mode Exit fullscreen mode

Yayy! We have successfully set up devtron locally in our system and now we can start building features, fixing bugs, etc and start contributing to the project.

Discussion (2)

Collapse
xavidram profile image
xavidram

Great article. One thing to note. Currently Minikube is going through a bunch of issues with their latest updates. Ingress not working, other plugins not working. Latest build not running properly or enabling addons correctly. Etc

github.com/kubernetes/minikube/issues

So if you are looking to do local development. Look for an older version of minikube where all features work.

Collapse
arushi09 profile image
Arushi shukla Author

Hi There ,
Thank you for your appreciation and i will surely look into. 👍