The elastic agent profile, apart from having docker container configurations, provides an ability to configure an EC2 Instance. This would be useful in cases where a docker container cannot be created on the EC2 Instance provisioned using configurations provided in the cluster profile.
- Navigate to Admin > Elastic Agent Configurations in the main menu
- Click the + Elastic Agent Profile button to create a new elastic agent profile within the specified cluster.
Note: Configuration settings marked with (*) are mandatory
Specify the properties for docker container(s) which will be used to spawn ECS elastic agents for GoCD.
-
Profile ID: Specify a unique ID for this profile.
-
Cluster Profile ID: This will be auto populated as you are creating elastic agent profile within the cluster profile.
-
Docker image (mandatory) Docker image to spin up the container. List of pre-built docker images for GoCD agents are available here. Here is information to build your own docker images.
-
Hard memory limit for container (mandatory) The maximum amount of memory that container is allowed to use. This field takes a positive integer, followed by a suffix of B, K, M, G and T to indicate bytes, kilobytes, megabytes, gigabytes or terabytes respectively. Read more about docker container memory.
-
Reserved memory for container (mandatory) The docker container will start with this amount of memory. This option is only available for
Linux
platform. This field takes a positive integer, followed by a suffix of B, K, M, G and T to indicate bytes, kilobytes, megabytes, gigabytes or terabytes respectively. Read more about docker container memory. -
CPU (mandatory) The number of cpu units to reserve for the container. An EC2 instance has 1024 cpu units for every CPU core. This parameter specifies the minimum amount of CPU to reserve for a container. Read more about docker CPU constraints.
- Linux: If set to 0, container will only use unallocated CPU units. Unallocated CPU units are split equally between all containers.
- Windows: We recommend using at least 1024 CPU units (1 core) for Windows. Allocating lesser CPU units (including 0) will result in very slow running container.
-
Task role arn: Name of the IAM role to associate with the agent container. This can have any permission that is required by the given job. At the bare minimum your role must permit action
sts:AssumeRole
and allow access toecs-tasks.amazonaws.com
service.Bare minimum role template
{ "Version": "2012-10-17", "Statement": [ { "Sid": "", "Effect": "Allow", "Principal": { "Service": "ecs-tasks.amazonaws.com" }, "Action": "sts:AssumeRole" } ] }
-
Mount Docker Socket: Mounts the host
/var/run/docker.sock
to docker container. -
Privileged: When this parameter is true, the container is given elevated privileges on the host container instance. This is useful to run the docker in docker workflow. This can have security implications (since all docker containers can access the host docker server).
-
Docker Command: Specify the command to run in the container. Enter one parameter per line. This allows you to override the
CMD
that is specified in theDockerfile
, or provide one in case theDockerfile
does not contain aCMD
. Read more about docker's CMD. -
Environment Variables: Specify the environment variables. Enter one variable per line. This allows you to override the
ENV
that is specified in theDockerfile
, or provide new environment variables in case theDockerfile
does not contain anyENV
. Read more about docker's ENV.- Environment variables are resolved in following order:
- Elastic Profile: This will override the variable value specified in the cluster profile and
Dockerfile
. - Plugin Settings: This will override the variable value specified in
Dockerfile
. - Dockerfile: Variables defined in the
Dockerfile
have low precedence over other two. For example, variableFoo
defined in the cluster profile or elastic profile will override the variable with the same name defined inDockerfile
.
- Elastic Profile: This will override the variable value specified in the cluster profile and
- Environment variables are resolved in following order:
-
Bind Mount: Use bind mounts to mount one or more files or directories from the host machine on to the container. The BindMount configuration requires the following information:
-
Name: Name of the volume.
-
SourcePath: The path from the host machine that needs to be mounted on the container.
-
ContainerPath: The path on the container to mount the volume at.
Example BindMount Configuration
[ { "Name": "data", "SourcePath": "/ecs/data", "ContainerPath": "/var/data" } ]
Specify the configuration for the EC2 instance. This is optional. If specified, then the docker container(s) will be spawned on the EC2 instance matching the specified configuration. Otherwise, it will be spawned on an EC2 instance created using the configuration specified in the corresponding cluster profile.
-
AMI ID: This AMI ID will be used to spin up EC2 instances that will run docker containers with this profile. If left unspecified, the default AMI ID configured in the cluster profile will be used to spin up an EC2 instance. Read more about ECS optimized AMIs for Linux and Windows.
-
Instance type: This instance type will be used to spin up EC2 instances that will run docker containers with this profile. If left unspecified, the default instance type configured in the cluster profile will be used to spin up an EC2 instance. Read more about EC2 Instance Type.
-
IAM instance profile: The name of the IAM profile that will allow the ECS agent to make calls to AWS on your behalf. Please refer to pre-requisites for more information. If left unspecified, the
IAM Instance Profile
configured in the cluster profile will be used to spin up an EC2 instance. Read more about IAM Instance Profiles. -
Subnet id(s): Enter comma separated subnet ids. If multiple subnet ids are specified, the subnet having the least number of EC2 instances will be used to spin up a new EC2 instance. If left unspecified, the
Subnet id(s)
configured in the cluster profile will be used to spin up an EC2 instance. Read more about VPCs & Subnets. -
Security Group Id(s): Enter comma separated security group ids. EC2 instances will be assigned the security groups(s) specified here. If left unspecified, the
Security Group Id(s)
configured in the cluster profile will be used to spin up an EC2 instance. Read more about VP Security Groups. -
Spot Instance Configuration
- Run As Spot Instance: On selecting this option the plugin will run a docker container on an EC2 Spot Instance.
- Spot Price: The maximum price per hour that you are willing to pay for the Spot Instance. If not provided defaults to
On-Demand
Price. - Spot Request Expires After (in minutes): The plugin supports Spot Instances of type
one-time
.Spot Request Expires After (in minutes)
property is used to set the validity of the Spot Instance request from the time the request is created. Defaults to5
(minutes).
Note: Spot Instances can be terminated automatically by AWS. This plugin does not track Spot Instance interruption notices. On an instance termination, all jobs running on the spot instance will be eventually re-scheduled.
- Save your changes
Note: Configuration settings marked with (*) are mandatory