This guide provides a step-by-step walkthrough on deploying an application to a Kubernetes cluster using GitOps principles, leveraging Harness, Helm, and K3D. Screenshots accompany each step for clarity.
- Install K3D Using Brew
- Create a Local Kubernetes Cluster Using K3D
- Switch to the Respective Cluster Using
kubectl config current-context - Get K3D Cluster Nodes
- Install Harness Delegate onto K3D Cluster
- Create a GitHub Secret
- Configure Harness GitHub Connector
- Configure Harness K8s Cluster Connector
- Configure Harness K3D Local Environment
- Configure Harness K3D Infra Definition
- Configure Harness Service
- Create Harness K8s Pipeline
- Add a Pipeline Stage
- Add a Pipeline Service
- Add a Pipeline Environment
- Get Pods Running in Namespace
- Port Forward the Application Service for Testing
- Access the App from Browser
Install K3D, a lightweight Kubernetes distribution, using Homebrew. Run the following command:
brew install k3dThis ensures you have the necessary tools to create a Kubernetes cluster locally.
Create a local Kubernetes cluster with K3D using:
k3d cluster create kiran-local-clusterThis command sets up a new cluster named kiran-local-cluster.
Ensure you are using the correct context by running:
kubectl config current-contextVerify the output matches the desired cluster.
List the nodes in your K3D cluster:
kubectl get nodesThis confirms the nodes are ready and operational.
Deploy the Harness delegate to the cluster to facilitate communication with the Harness platform:
kubectl apply -f harness-delegate.yamlEnsure the delegate is up and running.
Generate a GitHub personal access token and create a Kubernetes secret:
kubectl create secret generic github-secret --from-literal=token=<YOUR_TOKEN>This will securely store your GitHub credentials in the cluster.
Set up a GitHub connector in the Harness platform to integrate your GitOps repository. This allows Harness to fetch Helm charts and manifests.
Connect the K3D cluster to Harness using the K8s connector. Provide the cluster details, including the API server URL and authentication method.
Define a Harness environment to represent the local K3D setup. Assign appropriate service and infrastructure definitions.
Set up an infrastructure definition in Harness to map to the K3D cluster. This includes namespace and cluster configuration details.
Create a Harness service for the application you wish to deploy. Specify deployment templates and artifacts.
Build a Kubernetes deployment pipeline in Harness. Add stages to automate the GitOps workflow.
Add a deployment stage to the pipeline. Define the steps for deploying your application to the K3D cluster.
Integrate the previously created service into the pipeline stage. This binds the pipeline to your application's configurations.
Attach the local K3D environment to the pipeline. This ensures deployments occur in the desired cluster.
Verify the application pods are running:
kubectl get pods -n <namespace>Check the status to ensure all pods are healthy.
Expose the application service locally for testing:
kubectl port-forward svc/<service-name> 8080:80 -n <namespace>Open your browser and navigate to:
http://localhost:8080
You should see your application up and running.
This end-to-end guide demonstrates deploying applications to a Kubernetes cluster using modern GitOps tools and practices. Feel free to explore and adapt it to your needs!# Deploy an Application to a Kubernetes Cluster Using GitOps, Harness, Helm, and K3D.
This end-to-end guide demonstrates deploying applications to a Kubernetes cluster using modern GitOps tools and practices. Feel free to explore and adapt it to your needs!

















