Skip to content

Envoy EDS service for AWS ECS Tasks or Cloudmap SRVs

License

Notifications You must be signed in to change notification settings

boostchicken/aws-ecs-eds

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aws-ecs-eds Docker Pulls GitHub Sponsors GitHub Workflow Status (with event)

Envoy EDS Service that automatically updates upstreams from AWS

AWS Integrations

AWS Elastic Container Service.

Gets privateIPv4Address of EC2/Fargate Tasks.

Port Resolution

  1. Environmental Variable: _aws.ecs.clusterName__port (e.g. us-west-2-fargate_port=8080)
  2. Default: 80

AWS Cloud Map

Reads SRV records from CloudMap

Port Resolution

  1. Environmental Variable: aws.cloudMap.serviceDiscoveryId_port (e.g. srv-1234_port=8080)
  2. instance['AWS_INSTANCE_PORT'] from ListInstances CloudMap API
  3. Default: 80

Envoy Config

TCP Listener Config

  1. Environmental Variable: EDS_LISTEN (e.g. 127.0.0.1:8080)
  2. Default: 0.0.0.0:5678
  3. All responses cached for 30 seconds on successful response

Config Snippet

eds-config.yaml

static_resources:
listeners:
- name: listener_0
address:
socket_address: { address: 0.0.0.0, port_value: 8080 }
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
stat_prefix: http_proxy
route_config:
name: local_route
virtual_hosts:
- name: local_service
domains: ["*"]
routes:
- match: { prefix: "/" }
route: { cluster: web }
http_filters:
- name: envoy.filters.http.router
clusters:
- name: web
connect_timeout: 10s
type: EDS
eds_cluster_config:
service_name: srv-qp3a4lugw4s5ei3a
eds_config:
resourceApiVersion: V3
api_config_source:
api_type: GRPC
transport_api_version: V3
grpc_services:
- envoy_grpc:
cluster_name: xds_cluster
- type: STATIC
connect_timeout: 10s
load_assignment:
cluster_name: xds_cluster
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: 10.0.0.5
port_value: 5678
http2_protocol_options: {}
name: xds_cluster

Custom Builds

Dockerfile

aws-ecs-eds/Dockerfile

Lines 1 to 13 in 2b29f88

FROM golang:1.16.4
ENV GOOS=linux
ENV GOARCH=amd64
COPY ./ /build
WORKDIR /build
RUN go mod vendor && go build -o aws-ecs-eds main.go
FROM amazonlinux:2
ENV EDS_LISTEN="0.0.0.0:5678"
EXPOSE 5678
WORKDIR /root/
COPY --from=0 /build/aws-ecs-eds /opt
CMD ["/opt/aws-ecs-eds"]