Automate Delegate Installation
You can automate Delegate installation and registration by duplicating the downloaded Delegate config file, renaming the Delegate, and applying the new file. You can script this process to duplicate Delegates as needed.
When you apply the new Delegate file it will register with Harness under the new name.
This topic will describe how to duplicate, rename, and register a new Delegate manually, but you will likely want to script this process.
In this topic:
- Before You Begin
- Review: Automation and High Availability (HA)
- Step 1: Duplicate the Delegate Config File
- Step 2: Rename the New Delegate
- Step 3: Install the New Delegate
- See Also
Before You Begin
Review: Automation and High Availability (HA)
Delegate Automation isn't required for all High Availability (HA) scenarios. Let's review Delegate HA and when automation might be beneficial.
You might need to install multiple Delegates depending on how many tasks you do concurrently, and on the compute resources you are providing to each Delegate. Typically, you will need one Delegate for every 300-500 service instances.
In addition to compute considerations, you can enable High Availability (HA) for Harness Delegates. HA simply involves installing multiple Delegates in your environment.
For example, in Kubernetes deployments, you can set up two Kubernetes Delegates, each in its own pod in the same target K8s cluster. Simply edit the Kubernetes Delegate spec you download from Harness, harness-kubernetes.yaml, to have multiple
In this case, you do not need automation. Simply adding more
replicas will accomplish HA.
With two or more Delegates running in the same target environment, HA is provided by default. One Delegate can go down without impacting Harness' ability to perform deployments. If you want more availability, you can set up three Delegates to handle the loss of two Delegates, and so on.
- Two Delegates in different locations with different connectivity do not support HA. For example, if you have a Delegate in a Dev environment and another in a Prod environment, the Dev Delegate will not communicate with the Prod Delegate or vice versa. If either Delegate went down, Harness would not operate in their environment.
Step 1: Duplicate the Delegate Config File
Duplicate the config file for a Delegate you have installed and registered with your Harness account.
Ensure that the Delegate environment variables are set correctly.
The Delegate config file contains environment variables for account, Organization, and Project. The account variable is always set with your Harness account Id.
If your Delegate is registered at the account level, then the Organization and Project variables will be empty. If your Delegate is registered at the Organization level, then the Project variable will be empty.
If your Delegate config file uses other environment variables, review them to make certain that you want them duplicated.
Step 2: Rename the New Delegate
How you rename the Delegate depends on the type of Delegate. For Docker Delegates, you simply rename one environment variable in the Docker compose file.
For the Kubernetes Delegate, you need to multiple instances of the name.
Kubernetes Delegate Renaming
In the Kubernetes Delegate config file, several labels must be updated:
DELEGATE_NAME environment variable looks like this:
- name: DELEGATE_NAME
Docker Delegate Renaming
To rename the Docker Delegate, simply rename the value for the
DELEGATE_NAME environment variable.
Step 3: Install the New Delegate
Once the name(s) in the Delegate are updated, you can apply the Delegate and it will install and register with Harness.