-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Conversation
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
This pull request is being automatically deployed with Vercel (learn more). nomad-ui – ./ui🔍 Inspect: https://vercel.com/hashicorp/nomad-ui/7w8y3z6wg nomad-storybook – ./ui/stories🔍 Inspect: https://vercel.com/hashicorp/nomad-storybook/kuj9pgm80 |
Quick test: submit jobjob "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 |
There was a problem hiding this 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. |
There was a problem hiding this comment.
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...?
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. |
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