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

connect: enable setting connect upstream destination namespace #13125

Merged
merged 1 commit into from
May 26, 2022

Conversation

shoenig
Copy link
Member

@shoenig shoenig commented May 26, 2022

This PR enables setting destination_namespace for a Connect proxy upstream.

@shoenig
Copy link
Member Author

shoenig commented May 26, 2022

Quick example

➜ consul version 
Consul v1.12.1+ent
Revision cfd128ff
Protocol 2 spoken by default, understands 2 to 3 (agent will automatically use protocol >2 when speaking to compatible agents)

Using this PR cherry-picked onto nomad-enterpise because I'm too lazy to register Consul services by hand

➜ nomad version 
Nomad v1.3.2-dev+ent (10a88fa6cae490a24dac7403f381c1e8b34ae280+CHANGES)
consul namespace create -name ns1
consul namespace create -name ns2
job file
job "countdash" {
  datacenters = ["dc1"]

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

    consul {
      namespace = "ns1"
    }

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

      connect {
        sidecar_service {}
      }
    }

    task "web" {
      driver = "docker"

      config {
        image = "hashicorpnomad/counter-api:v3"
      }
    }
  }

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

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

    consul {
      namespace = "ns2"
    }

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

      connect {consul namespace create -name ns1
consul namespace create -name ns2

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

    task "dashboard" {
      driver = "docker"

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

      config {
        image = "hashicorpnomad/counter-dashboard:v3"
      }
    }
  }
}

@shoenig shoenig added backport/1.2.x backport to 1.1.x release line backport/1.3.x backport to 1.3.x release line labels May 26, 2022
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!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/1.2.x backport to 1.1.x release line backport/1.3.x backport to 1.3.x release line
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants