consul proxy change health endpoint

326 Views Asked by At

I have deployed a consul proxy on a different host than 'localhost' but consul keeps on checking health on 127.0.0.1.

Config of the service and it's sidecar:

service {
  name = "counting"
  id = "counting-1"
  port = 9005
  address = "169.254.1.1"

  connect {
  sidecar_service {
      proxy {
        config {
        bind_address = "169.254.1.1"
        bind_port = 21002
        tcp_check_address = "169.254.1.1"
        local_service_address = "localhost:9005"
        }
      }
  }
  }
  check {
    id       = "counting-check"
    http     = "http://169.254.1.1:9005/health"
    method   = "GET"
    interval = "10s"
    timeout  = "1s"
  }
}

The proxy was deployed using the following command:

consul connect proxy -sidecar-for counting-1 > counting-proxy.log

Consul UI's health check message: enter image description here

How do I change the health check to 169.254.1.1?

1

There are 1 best solutions below

0
On

First, I recommend using the Envoy proxy (consul connect envoy) instead of the built-in proxy (consul connect proxy) since the latter is not recommended for production use.

As far as changing the health check address, you can do that by setting proxy.local_service_address. This address is used when configuring the health check for the local application.

See https://github.com/hashicorp/consul/issues/11008#issuecomment-929832280 for a related discussion on this issue.