Integration with Harness: Minikube on WSL

A Guide to Using Harness with Minikube on Windows Subsystem for Linux (WSL)

Nelson Melo
Globant
7 min readJun 24, 2024

--

Image generated by Lexica AI

Do you want to improve your development workflow? You can do this by using Minikube in your Windows Subsystem for Linux (WSL) environment. Look no further. This comprehensive guide will walk you through setting up a local development environment.

Why Harness?

Before we dive into the details, let’s discuss why Harness is a game-changer for dev teams. Harness is a full Continuous Delivery-as-a-Service platform. Developers can automate application deployment and management on Kubernetes. Teams can use Harness to streamline their CI/CD pipelines. This will improve deployment reliability and speed up release cycles. It offers features like automated deployment verification, rollback, and scaling.

Prerequisites

In order to perform the required configuration, we need to complete the following prerequisites:

Install WSL

Follow the official Microsoft documentation to get started. WSL provides a light Linux environment on Windows. It lets you run Linux commands and tools.

Install Minikube

Once WSL is up and running, install Minikube with the Docker driver. Minikube offers many drivers for making Kubernetes clusters. Using the Docker driver is especially easy in WSL. This driver uses Docker containers to start the Kubernetes cluster. It removes the need for a separate virtual machine.

To install Minikube with the Docker driver, follow the official Minikube docs. Choose the Docker driver option during installation. Ensure you have installed and set up Docker in your WSL environment.

After installing Minikube, start it in WSL by running this command:

minikube start

This command will start a local Kubernetes cluster using Minikube.

Install Helm

You need to install Helm on your WSL to use it as a Kubernetes package manager. Follow the official Helm documentation to install Helm on your local machine.

Integrating with Harness

Once we have Minikube, it’s time to integrate it with Harness. This will streamline your development workflow.

Sign Up for Harness

If you haven’t already signed up for Harness, go to their website and create an account. Harness offers a free trial, allowing you to explore its features and capabilities. Once you’ve signed up, log in to your Harness account to access the platform.

Create a Delegate with Helm

Harness utilizes delegates to ease deployment and management tasks. The delegate is an agent installed in your target deployment environment. It runs workflows and talks to your infrastructure.

Harness CD SaaS Architecture

To create a delegate using Helm in Harness, start by navigating to the Harness portal and accessing Project Settings. Next, examine the Project-level resources and select the Delegates option:

Project-level resources in Project Settings

Then, click on the +New Delegate button:

+New Delegate button

Finally, proceed by following the provided instructions to deploy the Helm Chart. The result should be:

Helm delegates on Harness web interface

Create a Connector to Minikube and Docker Registry

Harness utilizes connectors to ease deployment and management tasks. A connector is a configuration entity in Harness. It defines the connection details and authentication for accessing your deployment targets.

To create a Minikube Connector, begin by navigating to Project Settings in the Harness portal. Next, review the Project-level resources and choose Connectors. Click on the +New Connector button:

+New Connector button

Thereafter, select Kubernetes cluster in the Connectors window, as shown in the following image:

Types of connectors for cloud providers

Enter a name for the connector, such as “minikube connector”:

Kubernetes Cluster connector window

Choose the method to authenticate to your Minikube cluster using the option Use the credentials of a specific Harness Delegate, which allows the connector to inherit the credentials used by the Harness Delegate:

Authentication method into Kubernetes Cluster connector

Finally, select the delegate you created earlier and check the connectivity. The result should be:

Minikube connector on Harness web interface

To create a Docker Registry Connector, begin by navigating to Project Settings in the Harness portal. Next, review the Project-level resources and select Connectors. Click on the +New Connector button and choose Docker Registry in the Connectors window, as shown in the following image:

Types of connectors for artifact repositories

Enter a name for the connector, such as “docker registry connector”. Choose the provider type and the authentication method, as shown in the following image:

Details of docker registry connector

Finally, select Connect through Harness Platform and check the connectivity. The result should be:

Docker connector on Harness web interface

Create a Pipeline in Harness

Harness provides intuitive tools for the construction and administration of deployment pipelines. In this phase, we will create a pipeline, and also we will show you how to use a custom stage. Harness offers both a visual interface and a YAML version for pipeline definition, we will review both ways to create a pipeline.

Using the Harness Portal

To accomplish this, start by navigating to Pipelines in the Harness portal. Click on the +Create a Pipeline button and name the Pipeline “python_example”, leaving the default values. Continue to click on the Start button to use the visual pipeline editor:

Create new Pipeline window

In the visual pipeline editor, add a Custom stage named “Using Python Docker Image”:

“Using Python Docker Image” stage in visual editor mode

Add a step, using the Add step option, and name it “python container” in the “Using Python Docker Image” stage.

Add step option into “Using Python Docker Image” stage

In the Step Library window, select Container Step:

Step library options for Add step

In the Configure Container Step window, add the necessary data, as shown in the following image:

Variables for “python container” in Configure Container Step window

The result should be:

“Using Python Docker Image” stage with “Python container” step in visual editor mode

Click on the Apply Changes button:

Apply Changes button in Configure Container Step window

After configuring the pipeline, save your changes using the Save button:

Save button in visual editor mode

Using the YAML configuration files

You can also use YAML with Harness. It lets you define pipelines with YAML files. Here’s an example YAML configuration for the previous python_example pipeline:

pipeline:
name: python_example
identifier: python_example
projectIdentifier: default_project
orgIdentifier: default
tags: {}
stages:
- stage:
name: Using Python Docker Image
identifier: Using_Python_Docker_Image
description: ""
type: Custom
spec:
execution:
steps:
- step:
type: Container
name: python container
identifier: python_container
spec:
connectorRef: docker_registry_connector
image: python:3.9
command: python --version
shell: Sh
infrastructure:
type: KubernetesDirect
spec:
connectorRef: minikube_connector
namespace: default
resources:
limits:
cpu: "0.5"
memory: 500Mi
annotations: {}
labels: {}
containerSecurityContext:
capabilities:
drop: []
add: []
nodeSelector: {}
reports:
type: JUnit
spec:
paths: []
outputVariables: []
envVariables: {}
timeout: 10m
tags: {}

Run the pipeline

Once you have created the python_example pipeline, you can run it. Select the pipeline from the list of pipelines in the Harness dashboard and click on the Run button.

List of pipelines in the Harness dashboard
“python_example” pipeline selected from the list of pipelines

Harness will execute the pipeline, orchestrating the deployment steps defined within it. You can track the pipeline’s progress in real time. You can also view its detailed logs and metrics to track its performance:

Pipeline console view output

By following the outlined steps, everyone can create and run a deployment pipeline in Harness. Automating and streamlining software delivery allows for efficiency. This improves its effectiveness.

Conclusion

You can use Minikube and Harness to make development smooth in your WSL environment. You may be building, testing, or deploying apps, Harness makes the process simpler, as it will let you focus on what matters most: delivering high-quality software faster. With Harness, you can automate repetitive tasks, removing manual errors. It will also ensure the team follows consistent deployment practices.

References

--

--