Skip to content

kirananil007/k8s-gitops-helm-deploy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Deploy an Application to a Kubernetes Cluster Using GitOps, Harness, Helm, and K3D

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.


Table of Contents

  1. Install K3D Using Brew
  2. Create a Local Kubernetes Cluster Using K3D
  3. Switch to the Respective Cluster Using kubectl config current-context
  4. Get K3D Cluster Nodes
  5. Install Harness Delegate onto K3D Cluster
  6. Create a GitHub Secret
  7. Configure Harness GitHub Connector
  8. Configure Harness K8s Cluster Connector
  9. Configure Harness K3D Local Environment
  10. Configure Harness K3D Infra Definition
  11. Configure Harness Service
  12. Create Harness K8s Pipeline
  13. Add a Pipeline Stage
  14. Add a Pipeline Service
  15. Add a Pipeline Environment
  16. Get Pods Running in Namespace
  17. Port Forward the Application Service for Testing
  18. Access the App from Browser

1. Install K3D Using Brew

Install K3D, a lightweight Kubernetes distribution, using Homebrew. Run the following command:

brew install k3d

Install K3D Using Brew

This ensures you have the necessary tools to create a Kubernetes cluster locally.

2. Create a Local Kubernetes Cluster Using K3D

Create a local Kubernetes cluster with K3D using:

k3d cluster create kiran-local-cluster

Create a Local Kubernetes Cluster

This command sets up a new cluster named kiran-local-cluster.

3. Switch to the Respective Cluster Using kubectl config current-context

Ensure you are using the correct context by running:

kubectl config current-context

Switch to the Respective Cluster

Verify the output matches the desired cluster.

4. Get K3D Cluster Nodes

List the nodes in your K3D cluster:

kubectl get nodes

Get k3d nodes

This confirms the nodes are ready and operational.

5. Install Harness Delegate onto K3D Cluster

Deploy the Harness delegate to the cluster to facilitate communication with the Harness platform:

kubectl apply -f harness-delegate.yaml

Install harness delegate

Ensure the delegate is up and running.

6. Create a GitHub Secret

Generate a GitHub personal access token and create a Kubernetes secret:

kubectl create secret generic github-secret --from-literal=token=<YOUR_TOKEN>

Create harness github secret

This will securely store your GitHub credentials in the cluster.

7. Configure Harness GitHub Connector

Set up a GitHub connector in the Harness platform to integrate your GitOps repository. This allows Harness to fetch Helm charts and manifests.

Create harness github connector

8. Configure Harness K8s Cluster Connector

Connect the K3D cluster to Harness using the K8s connector. Provide the cluster details, including the API server URL and authentication method.

Create harness k8s connector

9. Configure Harness K3D Local Environment

Define a Harness environment to represent the local K3D setup. Assign appropriate service and infrastructure definitions.

Create harness k8s environment

10. Configure Harness K3D Infra Definition

Set up an infrastructure definition in Harness to map to the K3D cluster. This includes namespace and cluster configuration details.

Create harness k8s infra definition

11. Configure Harness Service

Create a Harness service for the application you wish to deploy. Specify deployment templates and artifacts.

Create harness service

12. Create Harness K8s Pipeline

Build a Kubernetes deployment pipeline in Harness. Add stages to automate the GitOps workflow.

Create harness k8s pipeline

13. Add a Pipeline Stage

Add a deployment stage to the pipeline. Define the steps for deploying your application to the K3D cluster.

Create harness k8s pipeline stage

14. Add a Pipeline Service

Integrate the previously created service into the pipeline stage. This binds the pipeline to your application's configurations.

Create harness k8s pipeline service

15. Add a Pipeline Environment

Attach the local K3D environment to the pipeline. This ensures deployments occur in the desired cluster.

Create harness k8s pipeline environment

16. Get Pods Running in Namespace

Verify the application pods are running:

kubectl get pods -n <namespace>

Get pods

Check the status to ensure all pods are healthy.

17. Port Forward the Application Service for Testing

Expose the application service locally for testing:

kubectl port-forward svc/<service-name> 8080:80 -n <namespace>

Port forward

18. Access the App from Browser

Open your browser and navigate to:

http://localhost:8080

Port forward

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!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors