Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consul Connect over IPv6 (except tproxy) #24203

Merged
merged 3 commits into from
Oct 14, 2024

Conversation

gulducat
Copy link
Member

@gulducat gulducat commented Oct 14, 2024

Mostly resolves #7905 -- #23882 introduced IPv6 support to Nomad's "bridge" network mode, and this extends that to Consul Connect (which also requires "bridge" mode). I say "mostly" because Transparent Proxy still does not work (the Consul CNI plugin does not do any ip6tables at the moment for its extra functionality).

Along the way, I found that since we were always setting Connect/Envoy's bind_address to "0.0.0.0", the user couldn't pick anything else (like I had tried "::"). In particular, even with this PR auto-detecting IPv6, I imagine a user might like to set it to "" (empty), so that Consul proxy-defaults config can come into play. I did not add a config option for the client along these lines, but an individual job could set it like so:

connect {
  sidecar_service {
    proxy {
      config {
        bind_address = "" # let consul proxy-defaults handle it
      }

Or set it to whatever they may like.


My preferred way to replicate the behavior is (on a host/network with ipv6 support), enable ipv6 on the Nomad bridge and prefer ipv6 for services on a client (per #23388):

client {
  enabled = true

  bridge_network_subnet_ipv6 = "fd00:a110:c8::/120"
  preferred_address_family   = "ipv6"
}

Consul can run in dev mode. consul agent -dev

Then use the basic countdash example:

$ nomad job init -connect -short
Example job file written to example.nomad.hcl
example.nomad.hcl
job "countdash" {

  group "api" {
    network {
      mode = "bridge"
    }

    service {
      name = "count-api"
      port = "9001"

      connect {
        sidecar_service {}
      }
    }

    task "web" {
      driver = "docker"

      config {
        image          = "hashicorpdev/counter-api:v3"
        auth_soft_fail = true
      }
    }
  }

  group "dashboard" {
    network {
      mode = "bridge"

      port "http" {
        static = 9002
        to     = 9002
      }
    }

    service {
      name = "count-dashboard"
      port = "9002"

      connect {
        sidecar_service {
          proxy {
            upstreams {
              destination_name = "count-api"
              local_bind_port  = 8080
            }
          }
        }
      }
    }

    task "dashboard" {
      driver = "docker"

      env {
        COUNTING_SERVICE_URL = "http://${NOMAD_UPSTREAM_ADDR_count_api}"
      }

      config {
        image          = "hashicorpdev/counter-dashboard:v3"
        auth_soft_fail = true
      }
    }
  }
}

The alloc and service addresses will be ipv6, health checks pass, and the counter counts.

specifically service.connect.sidecar_proxy.config.bind_address
so that "::" can be passed in, for example, for ipv6,
or "" to allow consul proxy-defaults to set it to anything else.
@gulducat gulducat added theme/networking theme/ipv6 theme/consul/connect Consul Connect integration backport/1.9.x backport to 1.9.x release line labels Oct 14, 2024
@gulducat gulducat requested review from shoenig and tgross October 14, 2024 19:35
"bind_port": 42,
"envoy_stats_tags": []string{"nomad.alloc_id=test_alloc1b"},
}, connectProxyConfig(map[string]interface{}{
"bind_address": "anything",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kind of invalid input just blows up downstream, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, with this "anything" for example, the sidecar logs will show envoy squawking like

[2024-10-14 20:36:19.901][1][warning][config] [source/extensions/config_subscription/grpc/delta_subscription_state.cc:269] delta config for type.googleapis.com/envoy.config.listener.v3.Listener rejected: Error adding/updating listener(s) public_listener:anything:28417: malformed IP address: anything
[2024-10-14 20:36:19.901][1][warning][config] [source/extensions/config_subscription/grpc/grpc_subscription_impl.cc:138] gRPC config for type.googleapis.com/envoy.config.listener.v3.Listener rejected: Error adding/updating listener(s) public_listener:anything:28417: malformed IP address: anything

It will continue running, but the "Connect Sidecar Listening" health check fails.

So maybe it doesn't quite "blow up" but it's not too hard to track down.

command/agent/consul/connect_test.go Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/1.9.x backport to 1.9.x release line theme/consul/connect Consul Connect integration theme/ipv6 theme/networking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consul Connect doesn't work with IPv6
2 participants