简体   繁体   中英

ECS fargate with consul-agent and proxy as sidecar container

I am trying to implement consul-agent and proxy as sidecar container inside my ECS fargate service. So, inside the task, there will be 3 containers running:

  • core-business-service-container
  • consul-agent-container
  • core-business-consul-proxy-container

All containers are up and running on ECS task. The node has registered in the consul UI as well. But, the service is not up in the consul UI.

I dig in and found the log of 'consul-agent-container', Here is the error log:

2021/03/12 03:33:14 [ERR] http: Request PUT /v1/agent/check/pass/greeting-fargate-proxy-ttl?note=, error: CheckID "greeting-fargate-proxy-ttl" does not have associated TTL from=127.0.0.1:43252

Here are the commands I used to connect consul.

  1. consul-agent-container:

"exec consul agent -ui -data-dir /consul/data -client="127.0.0.1" -bind="{{ GetPrivateIP }}" -retry-join "172.31.79.139""

  1. core-business-consul-proxy-container:

"exec consul connect proxy -register -service greeting-fargate -http-addr 127.0.0.1:8500 -listen 127.0.0.1:8080 -service-addr 127.0.0.1:3000"

HashiCorp recently announced support for running Consul service mesh on ECS using Terraform to deploy the agent and sidecar components. You might want to consider this as an alternative solution to your existing workflow.

This solution is currently in tech preview. You can find more information in the blog post https://www.hashicorp.com/blog/announcing-consul-service-mesh-for-amazon-ecs .

I did not manage to get my proxy to work using the same method as you were using. But I remember reading somewhere that you should declare your Connect proxy inside the service registration config

  {
  "service": {
    "name": "web",
    "port": 8080,
    "connect": { "sidecar_service": {} }
  }
}

After you have done that I think you could just launch your proxy using:

consul connect proxy -sidecar-for <service-id>

I did not verify this because the application I was using used Spring Cloud Consul to register the services and I did not find where to register a proxy, but maybe this can help you further.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM