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

Backport of Add support for Nomad transparent proxy into release/1.4.x #3830

Conversation

hc-github-team-consul-core

Backport

This PR is auto-generated from #3795 to be assessed for backporting due to the inclusion of the label backport/1.4.x.

The below text is copied from the body of the original PR.


Nomad will implement support for Connect transparent proxy. Unlike in K8s, the
CNI plugin can't contact the Nomad API to read allocation metadata (pod labels)
to get the iptables configuration, and doesn't use the rest of the Consul-K8s
control plane to inject that metadata. Instead, Nomad will pass the iptables
configuration JSON-serialized in the CNI arguments.

This changeset implements the behavior switch by detecting the IPTABLES_CONFIG
argument in the CNI arguments. This hypothetically allows for non-Nomad
workflows to use the same code path, if desired.

Ref: hashicorp/nomad#10628

How I've tested this PR

In addition to new unit tests, I ran a build of Nomad that includes hashicorp/nomad#20183, deployed as in production via systemd, along with a Consul agent configured to support DNS. Run the following Nomad job specification:

countdash with tproxy
job "countdash" {

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

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

      check {
        type     = "http"
        path     = "/health"
        expose   = true
        interval = "3s"
        timeout  = "1s"

        check_restart {
          limit = 0
        }
      }

      connect {
        sidecar_service {
          proxy {
            transparent_proxy {}
          }
        }
      }
    }

    task "web" {
      driver = "docker"

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

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

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

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

      check {
        type     = "http"
        path     = "/health"
        expose   = true
        interval = "3s"
        timeout  = "1s"

        check_restart {
          limit = 0
        }
      }

      connect {
        sidecar_service {
          proxy {
            transparent_proxy {}
          }
        }
      }
    }

    task "dashboard" {
      driver = "docker"

      env {
        COUNTING_SERVICE_URL = "http://count-api.virtual.consul:9001"
      }

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

Configure the following service intentions:

Kind = "service-intentions"
Name = "count-api"
Sources = [
  {
    Name   = "count-dashboard"
    Action = "allow"
  }
]

Once the job ran, I visited http://<nomad_ip_address>:9010 in my browser, and saw the countdash page with the green "connected" badge. All services appear healthy in the Consul UI.

How I expect reviewers to test this PR

  • Verify there's no interference with the existing k8s code paths
  • As I've done above, if necessary (although the only changes here are to argument parsing). You should be able to run nomad agent -dev -dev-connect on Linux along with a Consul agent to get a suitable reproduction.

Checklist


Overview of commits

Copy link
Member

@tgross tgross left a comment

Choose a reason for hiding this comment

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

LGTM

@hc-github-team-consul-core hc-github-team-consul-core merged commit 4883169 into release/1.4.x Mar 28, 2024
25 of 49 checks passed
@hc-github-team-consul-core hc-github-team-consul-core deleted the backport/cni-iptables-config-from-cni-args/presently-kind-jackal branch March 28, 2024 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants