Install the Harness ECS Delegate
The Harness Delegate is a service you run in your deployment target environment, such as your local network, VPC, or cluster. The Delegate connects all of your artifact, infrastructure, collaboration, verification and other providers with the Harness Manager.
Most importantly, the Delegate performs all deployment operations.
There are several types of Delegates. This topic describes how to install the ECS Delegate.
In this topic:
- Before You Begin
- Visual Summary
- Review: ECS Requirements
- Review: ECS Task Spec
- Step 1: Install and Launch the ECS Delegate
- Step 2: Register the ECS Task Spec in AWS
- Step 3: Create the ECS Service for ECS Delegate
- Delegate Groups
- See Also
Before You Begin
The following diagram shows how the Delegate enables Harness to integrate with all of your deployment resources:
Review: ECS Requirements
Ensure that your AWS account and the ECS cluster that will host the Delegate meet the following requirements:
- ecsInstanceRole — Ensure this role exists. See Amazon ECS Instance Role from AWS.
- ECS Role for Delegate: The Harness ECS Delegate requires an IAM role and policies to execute its deployment tasks (API calls, etc). Create a new IAM role named ECSDelegate that contains: AmazonEC2ContainerServiceforEC2Role and AmazonEC2ContainerServiceRole from AWS.
Attach all of these policies to one IAM role, or attach them all to ecsInstanceRole, and apply that to your ECS cluster as the Container instance IAM role when you create it.
- Customer Managed Policy named HarnessECS you create for using Application Auto Scaling:
Once you have your role set up, you can create your clusters.
- ECS Cluster for Harness Delegate: You will need an existing ECS cluster to run the Harness ECS Delegate. The cluster for the Harness ECS Delegate must meet the following requirements:
- EC2 Linux + Networking cluster.
- The ECS Cluster must have a minimum of 8GB memory for the Delegate. A m5.xlarge minimum is suggested.
- 1 registered container instance.
- AWS IAM Role containing the required policies, described above. Apply the role you created to this cluster.
Review: ECS Task Spec
As you have seen, the Harness ECS Delegate is downloaded as an ECS Task Spec that you can run as an ECS service in your ECS cluster.
Here is an example of a task definition that creates a Harness ECS Delegate as a service in your ECS cluster:
The cluster must have a minimum of 8GB of memory (t2.large minimum). Run the above command and the ECS Delegate will install as a service in your cluster. The Delegate will appear in the Setup > Harness Delegates page in a few minutes.
Step 1: Install and Launch the ECS Delegate
- Click Setup., and then click Harness Delegates.
- In the Delegate tab, click Install Delegate.
- In Download Type, select ECS Task Spec.
- In Delegate Group Name, enter the name for the Delegate group. For more information, see Delegate Groups below.
- In Profile, select a Delegate Profile. See Run Scripts on the Delegate using Profiles.
- If you are installing the Delegate in an ECS cluster, do not select Use AWS VPC Mode. Use AWS VPC Mode runs the ECS Delegate task with a FARGATE launch type.
- You can leave Hostname empty. ECS will use the default hostname Harness-ECS-Delegate.
- Click Download. The ECS Task Spec is downloaded. Next, you will use the AWS CLI to register the ECS Task Spec and then create the ECS service for the ECS Delegate.
Step 2: Register the ECS Task Spec in AWS
- Open a Terminal and navigate to the folder where you downloaded the ECS Task Spec.
- Extract the ECS Task Spec download.
tar -zxvf harness-delegate-ecs.tar.gz
- Navigate to the extracted folder:
- Log into AWS using your AWS Access Key ID and AWS Secret Key ID.
AWS Access Key ID [****************LPAA]: XXXXXXX
AWS Secret Access Key [****************4z52]: XXXXXXX
- Register the ECS task definition using the Harness ECS Task Spec.
aws ecs register-task-definition --cli-input-json file://ecs-task-spec.json
The JSON for the task is output.
- View the completed task.
aws ecs list-task-definitions
taskDefinitionArns is output.
Using the name of the ECS cluster for the Delegate, you will create the ECS service using the Task Definition. The cluster must have a minimum of 8GB of memory (m5ad.xlarge minimum).
Step 3: Create the ECS Service for ECS Delegate
- Create the ECS service using the task definition, providing the service name in
--service-name, cluster name in
--cluster, and the desired number of tasks in
--desired-count. The cluster will need a minimum of 8GB of memory per task.
aws ecs create-service --service-name ecs-tutorial --task-definition harness-delegate-task-spec --cluster ecs-tutorial --desired-count 1The output will display the JSON for the new service.
- View the new service.
aws ecs list-services --cluster ecs-tutorialThe output will display the new service:
- Wait 5 to 10 minutes for ECS to allocate resources for the service.
When ECS is ready, the new service is running in the cluster:
View the new ECS Delegate in Harness Manager.
- In Harness Manager, in the Harness Delegates page. When the ECS Delegate connects to the Harness Manager, it is listed with a status of Connected.
Congratulations! You are done installing and running the ECS Delegate.
ECS Delegates can be grouped to make it easier to manage multiple ECS Delegates.
To group ECS Delegates, you enter a name in the Delegate Group Name setting when you create each Delegate. You use the same name for each new Delegate you add.
The Delegate group is displayed in a single expand/collapse (accordion) panel.
When you change a Selector, Profile, or Scope for a Delegate in the group, the change is applied to all Delegates running under that group.
Individual Delegates that are not grouped are called autonomous and are managed as individual Delegates.
When an ECS Delegate is stopped or offline, it will disappear from the Delegate list.