degica / barcelona

PaaS built on top of AWS
MIT License
52 stars 6 forks source link

Enable container metadata for ECS #801

Closed showwin closed 10 months ago

showwin commented 10 months ago

Context

We are setting up ddagent as daemon service on ECS. The hats containers need to know the EC2 host private IP address to communicate with the service-daemon ddagent, ref. The container can get the IP address by cat $ECS_CONTAINER_METADATA_FILE | jq -r .HostPrivateIPv4Address as explained in the above document, but this environment variable is blank by default. We need to turn on the container metadata by defining ECS_ENABLE_CONTAINER_METADATA=true in ECS config, ref.

Steps after merging this PR

For staging:

  1. ~bcn district apply staging~ This is not required since the ECS config file id pulled from S3.
  2. ~Go to CF page on console and apply changes~
  3. Use Instance Refresh feature with 90% minimum healthy instance to replace existing servers.

For production:

  1. Confirm the setting works well on staging
  2. ~bcn district apply komoju~
  3. Use Instance Refresh feature with 90% minimum healthy instance to replace existing servers.

@davidsiaw I'd like you to review the post-merge steps as well πŸ™

degikko commented 10 months ago

@davidsiaw can you help us review this PR, please?

davidsiaw commented 10 months ago

I had a quick look and wondered why we didn't do this but came across this. I am not sure if this is something we want to depend on?

γ‚Ήγ‚―γƒͺγƒΌγƒ³γ‚·γƒ§γƒƒγƒˆ 2023-10-31 17 12 46
showwin commented 10 months ago

When we move to Fargate, we cannot use daemon service for ddagent. So, we will change the architecture to use side-car model.

Screenshot 2023-10-31 at 17 21 44

link: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs_services.html

I guess we can start using the side-car model from now on, but I don't know the background of the current decision well. As far as I can guess, the daemon service is a bit cost-efficient compared to side-car.

showwin commented 10 months ago

@davidsiaw It's by Terraform and this is the PR, https://github.com/degica/terraform-modules/pull/40.

showwin commented 9 months ago

Just a note in the future: I needed to execute bcn district apply <district> command to upload the ECS config file to S3. (but you won't see any changes on the change set in CloudFormation)