Skip to main content

Harness CLI Examples

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

  1. Refer Install and Configure Harness CLI doc to setup and configure Harness CLI.

  2. Fork the harnesscd-example-apps repository through the GitHub web interface.

  3. Clone the Forked harnesscd-example-apps repo and change directory.

    git clone
    cd harnesscd-example-apps

    Replace GITHUB_ACCOUNTNAME with your GitHub Account name.

  4. Make 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 ArgoCD Agent.

  5. Before proceeding, store the Agent Identifier value as an environment variable for use in the subsequent commands:


    Note: Replace GITOPS_AGENT_IDENTIFIER with GitOps Agent Identifier.

  6. Create a GitOps Repository.

    harness gitops-repository --file guestbook/harness-gitops/repository.yml apply --agent-identifier $AGENT_NAME
  7. Create a GitOps Cluster.

    harness gitops-cluster --file guestbook/harness-gitops/cluster.yml apply --agent-identifier $AGENT_NAME
  8. Create a GitOps Application.

    harness gitops-application --file guestbook/harness-gitops/application.yml apply --agent-identifier $AGENT_NAME
  9. 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. Harness GitOps Sync Success

    • 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
  1. Congratulations! You successfully used harness CLI utility tool to create and execute a GitOps workflow.