hashicorp / consul

Consul is a distributed, highly available, and data center aware solution to connect and configure applications across dynamic, distributed infrastructure.
https://www.consul.io
Other
28.24k stars 4.41k forks source link

consul connect built in proxy doesn't respect bind_address and bind_port on service definition #10114

Open rumeshmadhusanka opened 3 years ago

rumeshmadhusanka commented 3 years ago

Overview of the Issue

I want to deploy consul connect built in proxy on a different host rather than localhost. Though I define that in service definition. It seems consul thinks that side car is always deployed on localhost

Reproduction Steps

My service definition:

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 = "169.254.1.1:9005"
        }
      }
  }
  }
  check {
    id       = "counting-check"
    http     = "http://169.254.1.1:9005/health"
    method   = "GET"
    interval = "10s"
    timeout  = "1s"
  }
}

Consul's config.hcl file:

datacenter = "local-dc"
node_name = "machine"
server = true
data_dir = "/home/***/Downloads/wso2/consul.d"
encrypt = "jUfwm+1c1+rZZeP/lyG4LzWvh192geqpktXERrsdtEs="
ca_file = "/home/***/Downloads/***/consul-agent-ca.pem"
cert_file = "/home/***/Downloads/***/local-dc-server-consul-1.pem"
key_file = "/home/***/Downloads/***/local-dc-server-consul-1-key.pem"
verify_incoming = false
verify_outgoing = false
verify_server_hostname = false
acl = {
  enabled = false
  default_policy = "allow"
  enable_token_persistence = true
}
connect {
  enabled = true
}
ports {
  "grpc" = 8502
  "https" = 8051
}

consul started using:

consul agent -config-dir='/home/***/Downloads/***/consul.d' -node=machine -datacenter=local-dc -ui -https-port=8501 -server=true -bootstrap

consul is binded to a dummy interface created on :

{
  "client_addr": "169.254.1.1",
  "bind_addr": "169.254.1.1"
}

UI: Screenshot from 2021-04-24 10-33-28 Screenshot from 2021-04-24 10-32-02

Built in proxy:

consul connect proxy -sidecar-for counting-1

Screenshot from 2021-04-24 10-41-40

Consul info for both Client and Server

Used one consul instance

Server info ``` output from server 'consul info' command here ``` agent: check_monitors = 0 check_ttls = 0 checks = 3 services = 3 build: prerelease = revision = 10bb6cb3 version = 1.9.4 consul: acl = disabled bootstrap = true known_datacenters = 1 leader = true leader_addr = 169.254.1.1:8300 server = true raft: applied_index = 3350 commit_index = 3350 fsm_pending = 0 last_contact = 0 last_log_index = 3350 last_log_term = 20 last_snapshot_index = 0 last_snapshot_term = 0 latest_configuration = [{Suffrage:Voter ID:0012e53f-39c0-8676-861d-2eba72b3a8ee Address:169.254.1.1:8300}] latest_configuration_index = 0 num_peers = 0 protocol_version = 3 protocol_version_max = 3 protocol_version_min = 0 snapshot_version_max = 1 snapshot_version_min = 0 state = Leader term = 20 runtime: arch = amd64 cpu_count = 8 goroutines = 117 max_procs = 8 os = linux version = go1.15.8 serf_lan: coordinate_resets = 0 encrypted = true event_queue = 1 event_time = 20 failed = 0 health_score = 0 intent_queue = 0 left = 0 member_time = 1 members = 1 query_queue = 0 query_time = 1 serf_wan: coordinate_resets = 0 encrypted = true event_queue = 0 event_time = 1 failed = 0 health_score = 0 intent_queue = 0 left = 0 member_time = 1 members = 1 query_queue = 0 query_time = 1

Operating system and Environment details

Ubuntu 20.04 amd64

Log Fragments

Include appropriate Client or Server log fragments. If the log is longer than a few dozen lines, please include the URL to the gist of the log instead of posting it in the issue. Use -log-level=TRACE on the client and server to capture the maximum log detail.

rumeshmadhusanka commented 3 years ago

I deployed consul on a dummy interface 169.254.1.1 using the following commands on my Ubuntu:

sudo ip link add dummy0 type dummy
sudo ip addr add 169.254.1.1/24 dev dummy0
sudo ip link set dummy0 up

That's why you see 169.254.1.1 everywhere.

x4x commented 1 month ago

+1