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: enable setting datacenter in upstream #9472

Merged
merged 3 commits into from
Nov 30, 2020

Conversation

shoenig
Copy link
Member

@shoenig shoenig commented Nov 30, 2020

Before, upstreams could only be defined using the default datacenter.
Now, the datacenter field can be set in a connect upstream definition,
informing consul of the desire for an instance of the upstream service
in the specified datacenter. The field is optional and continues to
default to the local datacenter.

Closes #8964

Before, upstreams could only be defined using the default datacenter.
Now, the `datacenter` field can be set in a connect upstream definition,
informing consul of the desire for an instance of the upstream service
in the specified datacenter. The field is optional and continues to
default to the local datacenter.

Closes #8964
@vercel
Copy link

vercel bot commented Nov 30, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

nomad-ui – ./ui

🔍 Inspect: https://vercel.com/hashicorp/nomad-ui/7w8y3z6wg
✅ Preview: https://nomad-ui-git-f-connect-upstream-datacenter.hashicorp.vercel.app

nomad-storybook – ./ui/stories

🔍 Inspect: https://vercel.com/hashicorp/nomad-storybook/kuj9pgm80
✅ Preview: https://nomad-storybook-git-f-connect-upstream-datacenter.hashicorp.vercel.app

@shoenig
Copy link
Member Author

shoenig commented Nov 30, 2020

Quick test:

submit job

job "updc" {
  datacenters = ["dc1"]
  
  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
	      datacenter = "dc2"
            }
          }
        }
      }
    }

    task "dashboard" {
      driver = "docker"

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

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

check consul

$ curl -s localhost:8500/v1/catalog/service/count-dashboard-sidecar-proxy | jq -r .[0].ServiceProxy.Upstreams[0].Datacenter
dc2

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.

Code LGTM 👍 Would be nice to get a little more clarification around the default behavior in the docs.

@@ -80,6 +81,8 @@ job "countdash" {
- `destination_name` `(string: <required>)` - Name of the upstream service.
- `local_bind_port` - `(int: <required>)` - The port the proxy will receive
connections for the upstream on.
- `datacenter` `(string: <optional>)` - The datacenter in which to issue the
discovery query. Defaults to the local datacenter.
Copy link
Member

Choose a reason for hiding this comment

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

Can we be more specific about "local" here? The default looks like it ends up as "" (empty string). Is that the default datacenter for the server's Consul agent, or...?

@github-actions
Copy link

github-actions bot commented Dec 8, 2022

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 Dec 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Add datacenter tag in Upstream Stanza
2 participants