Manage services using Git Experience
When you create a new Harness service, you can store the service in one of the following ways:
- Inline: Harness stores the service in its platform.
- Remote: the Harness service is stored in Git.
You can set the service as Inline or Remote when the service is created, and then change the service storage method after it is created. Changing the storage method is described in this topic.
The topic explains how to use the Remote option to store your services in your Git platform account.
Before you begin
- Ensure you have a Git repo with at least one branch.
- Ensure you have a set up a Harness Git connector with a Personal Access Token (PAT) for your Git account.
Visual summary
Here's a quick video of how you can manage services, environments, and infrastructure definitions through Git Experience.
Create a remote service
You can create a service at the Harness account, organization, or project level. This topic explains the steps to create a service at the project level. The process is the same for the other levels.
To store a new service in a remote Git repo, do the following:
-
In your Harness account, go to a project.
-
In Project Settings, select Services. To learn more about creating services, go to Create Services.
-
Select New Service. The Add Service settings appear.
-
In Name, enter a name for the service.
-
In How do you want to set up your service, select Remote.
-
In Git Connector, select or create a Harness Git connector to the repo where you will store the service. For more information, go to Code Repo Connectors.
-
In Repository, select a repository. If your repository isn't listed, enter its name. Create the repository in Git before entering it in Select Repository. Harness does not create the repository for you.
-
In Git Branch, select a branch. If your branch isn't listed, enter its name. Create the branch in your repository before entering it in Git Branch. Harness does not create the branch for you. Save the service to the default branch on the first save. You can then create different branches in the Harness repo if you want to create different versions of your service.
Harness Git Experience auto-populates the YAML Path. You can change this path and the file name.
-
Select Save. You can see the repo details in the new service.
-
Click the YAML path to view your service YAML file in your Git repo.
Add remote services to a pipeline
Once the remote Harness service is created, you can use it in your CD pipeline. You can add a remote service to a pipeline regardless of whether the pipeline is inline or remote.
The Deployment Type of the remote service (Kubernetes, ECS, etc.) must match the Deployment Type of the stage where you are adding the service.
To add a remote service to a pipeline, do the following:
-
In your pipeline, go to the CD stage Service settings.
-
In Select Service, select the remote service.
-
Select the branch for the version of the service you want to use in your pipeline.
-
Select Apply Selected.
- When the remote service is linked to the pipeline, the branch of the service is displayed as
__DEFAULT__
.__DEFAULT__
resolves to the same branch as the pipeline when both the service linked to the pipeline are in the same repository. If the pipeline resides in a different repository, then DEFAULT resolved to the main branch of the repository where the linked service resides.
- If a remote stage template with a remote service is connected in a remote pipeline and both are in the same repository, the pipeline's branch defaults to the main branch. However, if the service is in a different repository it will not work.
Change an inline service to a remote service
You change a service stored from Inline to Remote and save it in a Git account.
- Select Services.
- Select More Options (⋮).
- Select Move to Git.
The same settings used when creating a remote service appear. Configure the settings just as you would for a new remote service.