-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from eiathom/TailAware-builds-load-balancing-se…
…rvice [TailAware] Builds load-balancing service
- Loading branch information
Showing
7 changed files
with
345 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,243 @@ | ||
AWSTemplateFormatVersion: 2010-09-09 | ||
Description: Public-facing ELB listening on port 80 for path "/v1/*" | ||
|
||
Parameters: | ||
VpcId: | ||
Type: AWS::EC2::VPC::Id | ||
Description: The VPC ID where the load balancer will be deployed | ||
Default: vpc-123456789 | ||
PublicLoadBalancerSecurityGroupId: | ||
Type: AWS::EC2::SecurityGroup::Id | ||
Description: The SecurityGroup Id associated to the public load balancer | ||
Default: Default | ||
PrivateSubnetIds: | ||
Type: List<AWS::EC2::Subnet::Id> | ||
Description: The Subnets (multiple for HA) configured for internal traffic only | ||
Default: subnet-4256274569,subnet-82458245802475 | ||
HttpTargetGroupArn: | ||
Type: String | ||
Description: The ARN of the HTTP target group | ||
Default: Default | ||
HttpTrafficPort: | ||
Type: Number | ||
Description: The port for HTTP traffic | ||
Default: 80 | ||
HttpTargetPort: | ||
Type: Number | ||
Description: The port for HTTP traffic to be forwarded to | ||
Default: 4318 | ||
OtelCollectorNamespaceName: | ||
Type: String | ||
Description: The name of the namespace for service discovery (discovery of Collectors hostnames) | ||
Default: otelcollector | ||
LoadBalancingCollectorMaxCapacity: | ||
Type: Number | ||
Description: The maximum number of tasks the LoadBalancing Collector should scale out to | ||
Default: 5 | ||
LoadBalancingCollectorMinCapacity: | ||
Type: Number | ||
Description: The minimum number of tasks the LoadBalancing Collector should scale in to | ||
Default: 1 | ||
LoadBalancingCollectorScalingTargetPercentage: | ||
Type: Number | ||
Description: The average memory utilisation percentage used to begin scaling the LoadBalancing Collector | ||
Default: 70 | ||
LoadBalancingCollectorServiceName: | ||
Type: String | ||
Description: The name of the load balancing collector service | ||
Default: loadbalancingcollector | ||
ImageName: | ||
Type: String | ||
Description: The image to leverage for the task | ||
Default: "otel/opentelemetry-collector:0.89.0" | ||
LoadBalancingCollectorDesiredCount: | ||
Type: Number | ||
Description: The desired number of initial tasks | ||
Default: 1 | ||
# 1024 == 1 CPU | ||
LoadBalancingCollectorCpu: | ||
Type: Number | ||
Default: 256 | ||
LoadBalancingCollectorMemory: | ||
Type: Number | ||
Default: 512 | ||
TelemetryBackendApiKeySsmKeyName: | ||
Type: AWS::SSM::Parameter::Name | ||
Description: Name of the SSM secret parameter key whose value is a telemetry backend API key | ||
Default: "/otel/collector/configuration/telemetry-backend-api-key" | ||
# value of the SSM variable is: env:COLLECTOR_CONFIGURATION | ||
LoadBalancingCollectorConfMap: | ||
Type: AWS::SSM::Parameter::Value<String> | ||
Description: Name of the SSM parameter key whose value points to the location of the Collector configuration | ||
Default: "/otel/collector/configuration/loadbalancing-collector-conf-map-type" | ||
LoadBalancingCollectorConfigurationYaml: | ||
Type: AWS::SSM::Parameter::Value<String> | ||
Description: Name of the SSM parameter key whose value is the actual configuration | ||
Default: "/otel/collector/configuration/loadbalancing-collector-configuration" | ||
|
||
Resources: | ||
PrivateServiceSecurityGroup: | ||
Type: AWS::EC2::SecurityGroup | ||
Properties: | ||
GroupDescription: Allow traffic from public ALB to private ECS | ||
VpcId: !Ref VpcId | ||
SecurityGroupIngress: | ||
- IpProtocol: tcp | ||
FromPort: !Ref HttpTrafficPort | ||
ToPort: !Ref HttpTrafficPort | ||
SourceSecurityGroupId: !Ref PublicLoadBalancerSecurityGroupId | ||
|
||
OtelCollectorCluster: | ||
Type: AWS::ECS::Cluster | ||
|
||
OtelCollectorCloudMapNamespace: | ||
Type: AWS::ServiceDiscovery::PrivateDnsNamespace | ||
Properties: | ||
Name: !Sub "${OtelCollectorNamespaceName}.local" | ||
Vpc: !Ref VpcId | ||
|
||
# LoadBalancingCollector: Scalable Service | ||
LoadBalancingCollectorDiscovery: | ||
Type: AWS::ServiceDiscovery::Service | ||
Properties: | ||
Name: loadbalancingcollector | ||
NamespaceId: !Ref OtelCollectorCloudMapNamespace | ||
|
||
ECSTaskRole: | ||
Type: AWS::IAM::Role | ||
Properties: | ||
Description: Allows ECS tasks to call AWS services on your behalf | ||
AssumeRolePolicyDocument: | ||
Version: "2012-10-17" | ||
Statement: | ||
- Sid: "" | ||
Effect: Allow | ||
Principal: | ||
Service: ecs-tasks.amazonaws.com | ||
Action: "sts:AssumeRole" | ||
Policies: | ||
- PolicyName: AwsTelemetryPolicy | ||
PolicyDocument: | ||
Version: "2012-10-17" | ||
Statement: | ||
- Effect: Allow | ||
Action: | ||
- "logs:PutLogEvents" | ||
- "logs:CreateLogGroup" | ||
- "logs:CreateLogStream" | ||
- "logs:DescribeLogStreams" | ||
- "logs:DescribeLogGroups" | ||
- "xray:PutTraceSegments" | ||
- "xray:PutTelemetryRecords" | ||
- "xray:GetSamplingRules" | ||
- "xray:GetSamplingTargets" | ||
- "xray:GetSamplingStatisticSummaries" | ||
- "ssm:GetParameters" | ||
Resource: "*" | ||
|
||
ECSTaskExecutionRole: | ||
Type: AWS::IAM::Role | ||
Properties: | ||
AssumeRolePolicyDocument: | ||
Version: "2012-10-17" | ||
Statement: | ||
- Sid: "" | ||
Effect: Allow | ||
Principal: | ||
Service: ecs-tasks.amazonaws.com | ||
Action: "sts:AssumeRole" | ||
ManagedPolicyArns: | ||
- "arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy" | ||
- "arn:aws:iam::aws:policy/CloudWatchLogsFullAccess" | ||
- "arn:aws:iam::aws:policy/AmazonSSMReadOnlyAccess" | ||
|
||
LoadBalancingCollectorTaskDefinition: | ||
Type: AWS::ECS::TaskDefinition | ||
Properties: | ||
Family: !Ref LoadBalancingCollectorServiceName | ||
Cpu: !Ref LoadBalancingCollectorCpu | ||
Memory: !Ref LoadBalancingCollectorMemory | ||
NetworkMode: awsvpc | ||
RequiresCompatibilities: | ||
- FARGATE | ||
ExecutionRoleArn: !GetAtt ECSTaskExecutionRole.Arn | ||
TaskRoleArn: !GetAtt ECSTaskRole.Arn | ||
ContainerDefinitions: | ||
- Name: !Ref LoadBalancingCollectorServiceName | ||
Image: !Ref ImageName | ||
Cpu: !Ref LoadBalancingCollectorCpu | ||
Memory: !Ref LoadBalancingCollectorMemory | ||
PortMappings: | ||
- ContainerPort: !Ref HttpTargetPort | ||
Protocol: tcp | ||
AppProtocol: http | ||
Command: | ||
- "--config" | ||
- !Sub "${LoadBalancingCollectorConfMap}" | ||
Secrets: | ||
- Name: TELEMETRY_BACKEND_API_KEY | ||
ValueFrom: !Sub "arn:${AWS::Partition}:ssm:${AWS::Region}:${AWS::AccountId}:parameter${TelemetryBackendApiKeySsmKeyName}" | ||
Environment: | ||
- Name: COLLECTOR_CONFIGURATION | ||
Value: !Ref LoadBalancingCollectorConfigurationYaml | ||
LogConfiguration: | ||
LogDriver: awslogs | ||
Options: | ||
awslogs-create-group: "True" | ||
awslogs-group: !Ref LoadBalancingCollectorServiceName | ||
awslogs-region: !Ref "AWS::Region" | ||
awslogs-stream-prefix: otel | ||
|
||
LoadBalancingCollector: | ||
Type: AWS::ECS::Service | ||
Properties: | ||
ServiceName: !Ref LoadBalancingCollectorServiceName | ||
Cluster: !Ref OtelCollectorCluster | ||
TaskDefinition: !Ref LoadBalancingCollectorTaskDefinition | ||
LaunchType: FARGATE | ||
PropagateTags: SERVICE | ||
SchedulingStrategy: REPLICA | ||
DeploymentConfiguration: | ||
MaximumPercent: 200 | ||
MinimumHealthyPercent: 75 | ||
ServiceRegistries: | ||
- RegistryArn: !GetAtt LoadBalancingCollectorDiscovery.Arn | ||
DesiredCount: !Ref LoadBalancingCollectorDesiredCount | ||
NetworkConfiguration: | ||
AwsvpcConfiguration: | ||
AssignPublicIp: DISABLED | ||
Subnets: !Ref PrivateSubnetIds | ||
SecurityGroups: | ||
- !Ref PrivateServiceSecurityGroup | ||
LoadBalancers: | ||
- ContainerName: !Ref LoadBalancingCollectorServiceName | ||
ContainerPort: !Ref HttpTargetPort | ||
TargetGroupArn: !Ref HttpTargetGroupArn | ||
Tags: | ||
- Key: Name | ||
Value: !Join ["-", [!Ref LoadBalancingCollectorServiceName, "service"]] | ||
|
||
LoadBalancingCollectorScalingTarget: | ||
Type: "AWS::ApplicationAutoScaling::ScalableTarget" | ||
Properties: | ||
MaxCapacity: !Ref LoadBalancingCollectorMaxCapacity | ||
MinCapacity: !Ref LoadBalancingCollectorMinCapacity | ||
ResourceId: !Sub "service/${OtelCollectorCluster}/${LoadBalancingCollector}" | ||
ScalableDimension: "ecs:service:DesiredCount" | ||
ServiceNamespace: ecs | ||
|
||
# scaling the load balancing collector service task based on average memory utilisation | ||
LoadBalancingCollectorScalingPolicy: | ||
Type: "AWS::ApplicationAutoScaling::ScalingPolicy" | ||
Properties: | ||
PolicyName: LoadBalancingCollectorAutoScalingPolicy | ||
PolicyType: TargetTrackingScaling | ||
ScalingTargetId: !Ref LoadBalancingCollectorScalingTarget | ||
TargetTrackingScalingPolicyConfiguration: | ||
PredefinedMetricSpecification: | ||
PredefinedMetricType: "ECSServiceAverageMemoryUtilization" | ||
TargetValue: !Ref LoadBalancingCollectorScalingTargetPercentage | ||
# see: https://docs.aws.amazon.com/autoscaling/application/userguide/target-tracking-scaling-policy-overview.html#target-tracking-cooldown | ||
# in seconds, defaulting to both being 5 minutes of cooldown (this should be tuned after many load generation verification runs) | ||
ScaleInCooldown: 300 | ||
ScaleOutCooldown: 300 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.