The Harness Delegate is a software that gets installed in your environment which connects to Harness Manager and performs Continuous Delivery/Continuous Integration tasks.
In the Harness NextGen, ECS delegate can be deployed as a docker delegate both for ECS and ECS Fargate. This tutorial shows you how to install the Harness Delegate in an ECS cluster as an ECS service to enable the Delegate to connect to your AWS resources.
Delegate (Immutable image) on ECS
-
Create the cluster (n/w + ec2) type
-
Edit the below task-spec.json for
ACCOUNT_ID - Put your Harness Account ID
DELEGATE_TOKEN - Put your Delegate Token
MANAGER_HOST_AND_PORT - Put your manager host based on the Harness production cluster you are using
Prod1: https://app.harness.io
Prod2: https://app.harness.io/gratis
Prod3: https://app3.harness.io
DELEGATE_NAME - Put your Delegate Name
LOG_STREAMING_SERVICE_URL - Put your Log streaming service url based on the Harness production cluster you are using
Prod1: https://app.harness.io/log-service/
Prod2: https://app.harness.io/gratis/log-service/
Prod3: https://app3.harness.io/log-service/
task-spec.json:
{
"containerDefinitions": [
{
"portMappings": [
{
"hostPort": 8080,
"protocol": "tcp",
"containerPort": 8080
}
],
"cpu": 1,
"environment": [
{
"name": "ACCOUNT_ID",
"value": "<ACCOUNT_ID>"
},
{
"name": "DELEGATE_TOKEN",
"value": "<DELEGATE_TOKEN>"
},
{
"name": "DELEGATE_TYPE",
"value": "DOCKER"
},
{
"name": "INIT_SCRIPT",
"value": ""
},
{
"name": "DEPLOY_MODE",
"value": "KUBERNETES"
},
{
"name": "MANAGER_HOST_AND_PORT",
"value": "<MANAGER_HOST_AND_PORT>"
},
{
"name": "DELEGATE_NAME",
"value": "<DELEGATE_NAME>"
},
{
"name": "LOG_STREAMING_SERVICE_URL",
"value": "<LOG_STREAMING_SERVICE_URL>"
},
{
"name": "DELEGATE_TAGS",
"value": ""
},
{
"name": "NEXT_GEN",
"value": "true"
}
],
"memory": 2048,
"image": "harness/delegate:22.12.77802",
"essential": true,
"hostname": "<DELEGATE_HOST>",
"name": "<DELEGATE_NAME>"
}
],
"memory": "2048",
"requiresCompatibilities": [
"EC2"
],
"cpu": "1024",
"family": "harness-delegate-task-spec"
}
- Create AWS services and to increase the replica count change the desired count below:
aws ecs create-service --service-name <SERVICE_NAME> --task-definition
harness-delegate-task-spec --cluster <CLUSTER_NAME> --desired-count 1
Delegate (immutable image) on Fargate
-
Create the cluster n/w type
-
Edit the below task-spec.json for
ACCOUNT_ID - Put your Harness Account ID
DELEGATE_TOKEN - Put your Delegate Token
MANAGER_HOST_AND_PORT - Put your manager host based on the Harness production cluster you are using
Prod1: https://app.harness.io
Prod2: https://app.harness.io/gratis
Prod3: https://app3.harness.io
DELEGATE_NAME - Put your Delegate Name
LOG_STREAMING_SERVICE_URL - Put your Log streaming service url based on the Harness production cluster you are using
Prod1: https://app.harness.io/log-service/
Prod2: https://app.harness.io/gratis/log-service/
Prod3: https://app3.harness.io/log-service/
task-spec.json:
{
"containerDefinitions": [
{
"portMappings": [
{
"hostPort": 8080,
"protocol": "tcp",
"containerPort": 8080
}
],
"cpu": 1,
"environment": [
{
"name": "ACCOUNT_ID",
"value": "<ACCOUNT_ID>"
},
{
"name": "DELEGATE_TOKEN",
"value": "<DELEGATE_TOKEN>"
},
{
"name": "DELEGATE_TYPE",
"value": "DOCKER"
},
{
"name": "LOG_STREAMING_SERVICE_URL",
"value": "<LOG_STREAMING_SERVICE_URL>"
},
{
"name": "DELEGATE_TAGS",
"value": ""
},
{
"name": "INIT_SCRIPT",
"value": ""
},
{
"name": "DEPLOY_MODE",
"value": "KUBERNETES"
},
{
"name": "MANAGER_HOST_AND_PORT",
"value": "<HOST>"
},
{
"name": "DELEGATE_NAME",
"value": "<DELEGATE_NAME>"
},
{
"name": "NEXT_GEN",
"value": "true"
}
],
"memory": 2048,
"image": "harness/delegate:22.12.77802",
"essential": true,
"name": "ecs-delegate-im"
}
],
"executionRoleArn": "arn:aws:iam::<ACC_ID>:role/ecsTaskExecutionRole",
"memory": "6144",
"requiresCompatibilities": [
"FARGATE"
],
"networkMode": "awsvpc",
"cpu": "1024",
"family": "harness-delegate-task-spec"
}
- Edit the service.json
{
"launchType": "FARGATE",
"cluster": "<CLUSTER_NAME>",
"serviceName": "<SERVICE_NAME>",
"taskDefinition": "harness-delegate-task-spec",
"desiredCount": 1,
"loadBalancers": [],
"networkConfiguration": {
"awsvpcConfiguration": {
"subnets": [
"<SUBNET>"
],
"securityGroups": [
"SEC_GROUP"
],
"assignPublicIp": "ENABLED"
}
},
"platformVersion": "LATEST",
"schedulingStrategy": "REPLICA",
"enableECSManagedTags": true
}
- To register a task definition with a JSON file:
Task : aws ecs register-task-definition --cli-input-json
Service : aws ecs create-service --cli-input-json file://service.json