-
Notifications
You must be signed in to change notification settings - Fork 2k
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: fix bug where ingress gateways could not use wildcard services #10457
Conversation
… services This PR fixes a bug where Nomad was more restrictive on Ingress Gateway Configuration Entry definitions than Consul. Before, Nomad would not allow for declaring IGCEs with http listeners with service name "*", which is a special feature allowable by Consul. Note: to make http protocol work, a service-default must be defined setting the protocol to http for each service. Fixes: #9729
30ffc6d
to
3f317e2
Compare
Demo New behaviorSetup service defaults for our example service {
"Kind": "service-defaults",
"Name": "uuid-api",
"Protocol": "http",
"MeshGateway": {},
"Expose": {},
"CreateIndex": 170,
"ModifyIndex": 170
} Job with ingress gateway with wildcard http service job "w" {
datacenters = ["dc1"]
group "ingress-group" {
network {
mode = "bridge"
port "inbound" {
static = 8080
to = 8080
}
}
service {
name = "my-ingress-service"
port = "8080"
connect {
gateway {
ingress {
listener {
port = 8080
protocol = "http"
service {
name = "*" # this works now
}
}
}
}
}
}
}
group "generator" {
network {
mode = "host"
port "api" {}
}
service {
name = "uuid-api"
port = "api"
connect {
native = true
}
}
task "generate" {
driver = "docker"
config {
image = "hashicorpnomad/uuid-api:v5"
network_mode = "host"
}
env {
BIND = "0.0.0.0"
PORT = "${NOMAD_PORT_api}"
}
}
}
} Run job $ nomad job run w.nomad
==> Monitoring evaluation "24acde2e"
Evaluation triggered by job "w"
==> Monitoring evaluation "24acde2e"
Evaluation within deployment: "d484e9a1"
Allocation "943993c6" created: node "99ba54ec", group "ingress-group"
Allocation "bed3ba0b" created: node "99ba54ec", group "generator"
Evaluation status changed: "pending" -> "complete"
==> Evaluation "24acde2e" finished with status "complete" Query to the ingress gateway works $ curl -H "Host: uuid-api.ingress.dc1.consul:8080" $(dig +short @127.0.0.1 -p 8600 uuid-api.ingress.dc1.consul. ANY):8080
e1bc5cda-d1e6-992f-c617-ee9ef81b5531 Old job-submission rejection$ nomad job run w.nomad
Error submitting job: Unexpected response code: 500 (1 error occurred:
* Task group ingress-group validation failed: 1 error occurred:
* Task group service validation failed: 1 error occurred:
* Service[0] my-ingress-service validation failed: 1 error occurred:
* Consul Ingress Service requires one or more hosts when using HTTP protocol
) |
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.
LGTM!
// Validation of wildcard service name and hosts varies on whether the protocol | ||
// for the gateway is HTTP. | ||
// https://www.consul.io/docs/connect/config-entries/ingress-gateway#hosts | ||
switch isHTTP { |
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.
This switch feels like we're longing for better pattern matching in go, but 🤷♂️
consul/connect: fix bug where ingress gateways could not use wildcard services
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. |
This PR fixes a bug where Nomad was more restrictive on Ingress Gateway Configuration
Entry definitions than Consul. Before, Nomad would not allow for declaring IGCEs with
http listeners with service name "*", which is a special feature enabled by Consul.
Note: to make http protocol work, a
service-default
must be defined setting theprotocol
tohttp
for each service. (Settingprotocol
on the service definition in Consul is not possible)Fixes: #9729