Skip to main content

Add a Harness GitOps repository

This topic describes how to add a Harness GitOps repository containing the declarative description of a desired state.

Harness GitOps repositories are connections to repos containing the declarative description of a desired state. The declarative description can be in Kubernetes manifests, Helm Chart, Kustomize manifests, etc.

A Harness GitOps Repository is used for Harness GitOps only. For other Harness features like CI, CD Pipelines, etc, use a standard Git Connector.

Before you begin

If you are new to Harness GitOps, familiarize yourself with the following topics:

Supported platforms

  • Currently, only Git platforms, HTTP Helm servers, and OCI Helm repositories are supported in a GitOps repository.

Add a repository

In the repository setup, you will select the Agent to use when synching state. Be sure you have a GitOps Agent set up already.

For details, see Install a Harness GitOps Agent.

You will also provide the credentials to use when connecting to the Git repository. Ensure you have your credentials available.

If you use a GitOps repository credentials template with a GitOps repository, then the repository path in the GitOps repository must be a subfolder of the repository path in the repository credentials template.

  1. In your Harness project, select GitOps, and then select Settings.

  2. Select Repositories.

  3. Select New Repository.

  4. In Specify Repository Type, select:

    • Git to add Git repositories.
    • Helm to add HTTP Helm and OCI Helm repositories.
  1. In Specify Repository Type, select Git.

  2. In Repository Name, enter a name.

  3. In GitOps Agent, select or create the Agent you want to use to fetch manifests from this repo. For details, go to Install a Harness GitOps Agent.

  4. In Repository URL, enter the URL to your repo. For example, https://github.com/argoproj/argocd-example-apps.git.

  5. Select Continue.

  6. In Credentials, select one of the following:

    • Specify Credentials for Repository

      • In Credentials, in Connection Type, select HTTPS, or SSH, or GitHub App.
        • If you use Two-Factor Authentication for your Git repo, you connect over HTTPS or SSH.
        • For SSH, ensure that the key is not OpenSSH, but rather PEM format. To generate an SSHv2 key, use: ssh-keygen -t rsa -m PEM The rsa and -m PEM ensure the algorithm and that the key is PEM. Next, follow the prompts to create the PEM key.
        • For more information, see the ssh-keygen man page.
        • HTTP also has the Anonymous option.
      • For steps on setting up the GitHub App, go to Use a GitHub App in a GitHub Connector.
      • Select Save & Continue. Harness validates the connection.
    • Use a Credentials Template

      • Select the GitOps credentials template to use.

        For details, go to Harness GitOps Repository Credentials Template.

        If you use a repository credentials template for GitOps repository authentication, then the repository path in the GitOps repository must be a subfolder of the repository path in the repository credentials template.

        For example, if you created a repository credentials template for the URL https://something.com, GitOps repositories that have their URL as https://something.com/* are able to use that repository credentials template.

        Harness will auto-detect the repository credentials template (if any) based on the GitOps repository URL and auto-populate it. If Harness auto-populated the GitOps repository, then you cannot edit the repository credentials template setting.

    • Skip Server Verification

      Select this option to have the GitOps Agent skip verification of the URL and credentials.

      Verification is only skipped when you create the GitOps repository. Subsequent uses of the GitOps repository are verified.

    • Enable LFS Support

      Select the option to use Git Large File Storage.

    • Proxy

      A proxy for your repository can be specified in the proxy setting.

      Harness uses this proxy to access the repository. Harness looks for the standard proxy environment variables in the repository server if the custom proxy is absent.

      An example repository with proxy:

    apiVersion: v1  
    kind: Secret
    metadata:
    name: private-repo
    namespace: cd
    labels:
    argocd.argoproj.io/secret-type: repository
    stringData:
    type: git
    url: https://github.com/argoproj/private-repo
    proxy: https://proxy-server-url:8888
    password: my-password
    username: my-username
  7. Select Save & Continue. Harness validates the connection.

Skip server verification

Select this option to have the GitOps Agent skip verification of the URL and credentials.

Verification is only skipped when you create the GitOps repository. Subsequent uses of the GitOps repository are verified.

Verify connection

The connection is verified.

If you encounter errors, check that you have the correct repository URL and your authentication method has the required permissions.

Select Finish. You now have a Harness GitOps repository added.