Deploy using Kubernetes Manifest
This tutorial will get you started with Harness Continuous Delivery (CD). We will guide you through deploying a Guestbook application using Harness CD pipeline and GitOps methods. This Guestbook application uses a publicly available Kubernetes manifest and Docker image.
Kubernetes is required to complete these steps. Run the following to check your system resources and (optionally) install a local cluster.
bash <(curl -fsSL https://raw.githubusercontent.com/harness-community/scripts/main/delegate-preflight-checks/cluster-preflight-checks.sh)
- GitOps Workflow
- CD pipeline
Harness GitOps (built on top of Argo CD) watches the state of your application as defined in a Git repo, and can pull (either automatically, or when instructed to do so) these changes into your Kubernetes cluster, leading to an application sync. Harness GitOps supports both Argo CD and Flux CD as the GitOps reconciler.
Whether you're new to GitOps or an experienced practitioner, this guide will assist you in getting started with Harness GitOps, offering you the option to choose between Argo CD and Flux CD.
Before you begin
Verify that you have the following:
- A Kubernetes cluster. We recommend K3D for installing the Harness GitOps Agent and deploying a sample application in a local development environment.
- For requirements, go to Harness GitOps Agent Requirements.
- If you prefer using Flux CD as the reconciler, you will need to install the Flux controller on your Kubernetes cluster.
- Fork the harnesscd-example-apps repository through the GitHub web interface.
- For details on Forking a GitHub repository, go to GitHub docs.
Getting Started with Harness GitOps
- CLI
- UI
- Terraform Provider
-
Refer Install and Configure Harness CLI doc to setup and configure Harness CLI.
-
Clone the Forked harnessed-example-apps repo and change directory.
git clone https://github.com/GITHUB_ACCOUNTNAME/harnesscd-example-apps.git
cd harnesscd-example-appsnoteReplace
GITHUB_ACCOUNTNAME
with your GitHub Account name. -
Select Deployments, and then select GitOps.
GitOps Agent
What is a GitOps Agent?
A Harness GitOps Agent is a worker process that runs in your environment, makes secure, outbound connections to Harness, and performs all the GitOps tasks you request in Harness.
- Select Settings, and then select GitOps Agents.
- Select New GitOps Agent.
- When are prompted with Do you have any existing Argo CD instances?, select Yes if you already have a Argo CD Instance, or else choose No to install the Harness GitOps Agent.
- Harness GitOps Agent Fresh Install
- Harness GitOps Agent with existing Argo CD instance
-
Select No, and then select Start.
-
In Name, enter the name for the new Agent.
-
In Namespace, enter the namespace where you want to install the Harness GitOps Agent. Typically, this is the target namespace for your deployment.
- For this tutorial, let's use the
default
namespace to install the Agent and deploy applications.
- For this tutorial, let's use the
-
Select Continue. The Review YAML settings appear.
-
This is the manifest YAML for the Harness GitOps Agent. You will download this YAML file and run it in your Harness GitOps Agent cluster.
kubectl apply -f gitops-agent.yml -n default
-
Select Continue and verify the Agent is successfully installed and can connect to Harness Manager.
-
Select Yes, and then select Start.
-
In Name, enter the name for the existing Argo CD project.
-
In Namespace, enter the namespace where you want to install the Harness GitOps Agent. Typically, this is the target namespace for your deployment.
-
Select Next. The Review YAML settings appear.
-
This is the manifest YAML for the Harness GitOps Agent. You will download this YAML file and run it in your Harness GitOps Agent cluster.
kubectl apply -f gitops-agent.yml -n default
-
Once you have installed the Agent, Harness will start importing all the entities from the existing Argo CD Project.
-
Before proceeding, store the Agent Identifier value as an environment variable for use in the subsequent commands:
export AGENT_NAME=GITOPS_AGENT_IDENTIFIER
Note: Replace
GITOPS_AGENT_IDENTIFIER
with GitOps Agent Identifier. -
Create a GitOps Repository.
harness gitops-repository --file guestbook/harness-gitops/repository.yml apply --agent-identifier $AGENT_NAME
-
Create a GitOps Cluster.
harness gitops-cluster --file guestbook/harness-gitops/cluster.yml apply --agent-identifier $AGENT_NAME
-
Create a GitOps Application.
harness gitops-application --file guestbook/harness-gitops/application.yml apply --agent-identifier $AGENT_NAME
-
At last, it's time to synchronize the application with your Kubernetes setup.
-
Navigate to Harness UI > Default Project > GitOps > Applications, then click on gitops-application. Choose Sync, followed by Synchronize to kick off the application deployment.
-
Observe the Sync state as Harness synchronizes the workload under
Resource View
tab. -
After a successful execution, you can check the deployment in your Kubernetes cluster using the following command:
kubectl get pods -n default
- To access the Guestbook application deployed via the Harness pipeline, port forward the service and access it at http://localhost:8080:
kubectl port-forward svc/kustomize-guestbook-ui 8080:80
-
- Login to Harness.
- Select Projects, and then select Default Project.
- Select Deployments, and then select GitOps.