Hello all,
I'm running into a weird Consul connectivity issue that seems to be loopback-related. Here's all of the relevant info I could think of.
I'm running three Consul containers in a cluster. They will be used as a backend for Vault and Terraform. I also have two other servers, with each one running both a Vault container and a Consul container in client mode. All of the containers are using --net=host in Docker, and are on the same subnet with no firewall between them.
My Vault containers are configured to use Consul as a backend, and are configured to hit the local Consul agent on
127.0.0.1:8500 (because each Vault server also runs a Consul container bound to the same IP). The Consul agents are configured to bind to eth0.
All of my Consul agents are able to connect to each other and join a cluster, but my Vault servers can't communicate with Consul for some reason. Additionally, if I'm directly on a Consul node and try running "Consul Info", I get an error about not being able to communicate with Consul, even though I'm on the node itself.
If I'm on any of the servers with a Consul agent running, I can run "telnet <actual ip address> 8500" and get a successful connection, but if I run "telnet 127.0.0.1 8500", I get connection refused.
Here's an example of what I see from Vault (docker logs vault):
Here's what I see from Consul (consul info):
Here are the full "docker run" commands I'm using to fire up the containers:
docker container run -d --name=consul --net=host -v /etc/consul/data:/consul/data -v /etc/consul/config:/consul/config -e CONSUL_CLIENT_INTERFACE='eth0' -e CONSUL_BIND_INTERFACE='eth0' -p 8300:8300 -p 8301:8301 -p 8302:8302 -p 8500:8500 -p 8501:8501 -p 8600:8600 consul agent -ui -node {{ inventory_hostname }}
docker container run -d --name=vault --cap-add=IPC_LOCK --net=host -p 8200:8200 -p 8201:8201 -v /etc/vault/data:/vault/data -v /etc/vault/config:/vault/config -v /etc/vault/logs:/vault/logs -e VAULT_API_ADDR='https://{{ inventory_hostname }}:8200' -e VAULT_CLUSTER_ADDR='https://{{ inventory_hostname }}:8201' vault server
Here's my Vault config:
storage "consul" {
path = "vault/"
scheme = "http"
service = "vault"
tls_ca_file = "/vault/config/consul-ca.pem"
tls_cert_file = "/vault/config/client.pem"
tls_key_file = "/vault/config/client-key.pem"
tls_min_version = "tls12"
}
listener "tcp" {
tls_cert_file = "/vault/config/cert.crt"
tls_key_file = "/vault/config/key.key"
tls_min_version = "tls12"
}
Here's my Consul Client config. My server config is similar, except for server being set to true, and a bootstrap_expect of 3.
{
"datacenter": "companyname"
"data_dir": "/consul/data",
"encrypt": "jfieowjfieowjfieow",
"retry_join": [
],
"server": false,
"key_file": "/consul/config/client-key.pem",
"cert_file": "/consul/config/client.pem",
"ca_file": "/consul/config/consul-ca.pem",
"verify_incoming": true,
"verify_incoming_rpc": true,
"verify_outgoing": true
}
I'm running this on Ubuntu 18 and the latest version of Docker, using the official Vault and Consul containers. Anyone have any ideas on why I can't connect? I'm stuck right now so I'd really appreciate any pointers. Thanks in advance!