V0
In this segment, we'll guide you through a example demonstrating how to utilize the Harness CLI tool. You have the option to either establish a Harness GitOps workflow or configure a pipeline along with all necessary components to deploy a test guestbook application to your Kubernetes setup.
Let's Begin
Refer Install and Configure Harness CLI doc to setup and configure Harness CLI.
Fork the harnesscd-example-apps repository through the GitHub web interface.
Clone the Forked harnesscd-example-apps repo and change directory.
git clone https://github.com/GITHUB_ACCOUNTNAME/harnesscd-example-apps.git cd harnesscd-example-appsMake sure you have a GitOps Agent configured and running smoothly. If not, you can also refer to the Install Harness GitOps Agent for steps on creating a new Harness GitOps Agent or on utilizing existing Argo CD Agent.
Before proceeding, store the Agent Identifier value as an environment variable for use in the subsequent commands:
export AGENT_NAME=GITOPS_AGENT_IDENTIFIERNote: Replace
GITOPS_AGENT_IDENTIFIERwith GitOps Agent Identifier.Create a GitOps Repository.
harness gitops-repository --file guestbook/harness-gitops/repository.yml apply --agent-identifier $AGENT_NAMECreate a GitOps Cluster.
harness gitops-cluster --file guestbook/harness-gitops/cluster.yml apply --agent-identifier $AGENT_NAMECreate a GitOps Application.
harness gitops-application --file guestbook/harness-gitops/application.yml apply --agent-identifier $AGENT_NAMEAt 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 Viewtab.
After a successful execution, you can check the deployment in your Kubernetes cluster using the following command:
kubectl get pods -n defaultTo 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
Congratulations! You successfully used
harnessCLI utility tool to create and execute a GitOps workflow.
Refer Install and Configure Harness CLI doc to setup and configure Harness CLI.
Fork the harnesscd-example-apps repository through the GitHub web interface.
Clone the Forked harnesscd-example-apps repo and change directory.
Make sure you have a delegate configured and running smoothly. If not, you can also refer to the Install Harness Delegate on Kubernetes or Docker guide for steps on setting up the delegate using Helm, Terraform Helm Provider, or Kubernetes manifest.
Now, let's create all the resources that is required to execute a pipeline successfully. Let's start with creating a Harness Secret to store GitHub PAT.
Obtain GitHub personal access token with repo permissions. For steps, go to the GitHub documentation on creating a personal access token.
Create a Harness Secret to store GitHub PAT. This will be used in the next step to create GitHub connector.
Note: Replace
GITHUB_PATwith GitHub PAT that you obtained in the previous step.
Create a GitHub connector.
Note: Replace
GITHUB_ACCOUNTNAMEwith your GitHub Account Name.Create a Kubernetes connector.
Note: Replace
DELEGATE_NAMEwith the Delegate name.Create a Environment.
Create a Infrastructure Definition.
Create a Service.
Now, let's create a Pipeline of deployment type Canary with just a single command.
Finally, it's time to execute the pipeline. Traverse through
Harness UI>Default Project>Pipelines> Clickguestbook_canary_pipeline> Select Run, and then select Run Pipeline to initiate the deployment.Observe the execution logs as Harness deploys the workload and checks for steady state.
After a successful execution, you can check the deployment in your Kubernetes cluster using the following command:
To access the Guestbook application deployed via the Harness pipeline, port forward the service and access it at http://localhost:8080:
Congratulations! You successfully used
harnessCLI utility tool to create and execute a pipeline.
Last updated
Was this helpful?