consul/connect: enable setting local_bind_address in upstream

This commit is contained in:
Andre Ilhicas 2021-02-26 11:47:00 +00:00
parent f45fc6c899
commit 30c840e88e
No known key found for this signature in database
GPG Key ID: 43306F173FF8A8BF
3 changed files with 47 additions and 41 deletions

View File

@ -5,6 +5,8 @@ BUG FIXES:
* cli: Fixed a bug where non-int proxy port would panic CLI [[GH-10072](https://github.com/hashicorp/nomad/issues/10072)] * cli: Fixed a bug where non-int proxy port would panic CLI [[GH-10072](https://github.com/hashicorp/nomad/issues/10072)]
* cli: Fixed a bug where `nomad operator debug` incorrectly parsed https Consul API URLs. [[GH-10082](https://github.com/hashicorp/nomad/pull/10082)] * cli: Fixed a bug where `nomad operator debug` incorrectly parsed https Consul API URLs. [[GH-10082](https://github.com/hashicorp/nomad/pull/10082)]
IMPROVEMENTS:
* consul/connect: Enable setting `local_bind_address` field on connect upstreams [[GH-6248](https://github.com/hashicorp/nomad/issues/6248)]
## 1.0.4 (February 24, 2021) ## 1.0.4 (February 24, 2021)
FEATURES: FEATURES:

View File

@ -147,6 +147,7 @@ func interpolateConnectSidecarService(taskEnv *TaskEnv, sidecar *structs.ConsulS
for i := 0; i < len(sidecar.Proxy.Upstreams); i++ { for i := 0; i < len(sidecar.Proxy.Upstreams); i++ {
sidecar.Proxy.Upstreams[i].Datacenter = taskEnv.ReplaceEnv(sidecar.Proxy.Upstreams[i].Datacenter) sidecar.Proxy.Upstreams[i].Datacenter = taskEnv.ReplaceEnv(sidecar.Proxy.Upstreams[i].Datacenter)
sidecar.Proxy.Upstreams[i].DestinationName = taskEnv.ReplaceEnv(sidecar.Proxy.Upstreams[i].DestinationName) sidecar.Proxy.Upstreams[i].DestinationName = taskEnv.ReplaceEnv(sidecar.Proxy.Upstreams[i].DestinationName)
sidecar.Proxy.Upstreams[i].LocalBindAddress = taskEnv.ReplaceEnv(sidecar.Proxy.Upstreams[i].LocalBindAddress)
} }
sidecar.Proxy.Config = interpolateMapStringInterface(taskEnv, sidecar.Proxy.Config) sidecar.Proxy.Config = interpolateMapStringInterface(taskEnv, sidecar.Proxy.Config)
} }

View File

@ -164,41 +164,42 @@ func TestInterpolate_interpolateConnect(t *testing.T) {
t.Parallel() t.Parallel()
e := map[string]string{ e := map[string]string{
"tag1": "_tag1", "tag1": "_tag1",
"port1": "12345", "port1": "12345",
"address1": "1.2.3.4", "address1": "1.2.3.4",
"destination1": "_dest1", "destination1": "_dest1",
"datacenter1": "_datacenter1", "datacenter1": "_datacenter1",
"path1": "_path1", "localbindaddress1": "127.0.0.2",
"protocol1": "_protocol1", "path1": "_path1",
"port2": "_port2", "protocol1": "_protocol1",
"config1": "_config1", "port2": "_port2",
"driver1": "_driver1", "config1": "_config1",
"user1": "_user1", "driver1": "_driver1",
"config2": "_config2", "user1": "_user1",
"env1": "_env1", "config2": "_config2",
"env2": "_env2", "env1": "_env1",
"mode1": "_mode1", "env2": "_env2",
"device1": "_device1", "mode1": "_mode1",
"cidr1": "10.0.0.0/64", "device1": "_device1",
"ip1": "1.1.1.1", "cidr1": "10.0.0.0/64",
"server1": "10.0.0.1", "ip1": "1.1.1.1",
"search1": "10.0.0.2", "server1": "10.0.0.1",
"option1": "10.0.0.3", "search1": "10.0.0.2",
"port3": "_port3", "option1": "10.0.0.3",
"network1": "_network1", "port3": "_port3",
"port4": "_port4", "network1": "_network1",
"network2": "_network2", "port4": "_port4",
"resource1": "_resource1", "network2": "_network2",
"meta1": "_meta1", "resource1": "_resource1",
"meta2": "_meta2", "meta1": "_meta1",
"signal1": "_signal1", "meta2": "_meta2",
"bind1": "_bind1", "signal1": "_signal1",
"address2": "10.0.0.4", "bind1": "_bind1",
"config3": "_config3", "address2": "10.0.0.4",
"protocol2": "_protocol2", "config3": "_config3",
"service1": "_service1", "protocol2": "_protocol2",
"host1": "_host1", "service1": "_service1",
"host1": "_host1",
} }
env := NewTaskEnv(e, e, nil, nil, "", "") env := NewTaskEnv(e, e, nil, nil, "", "")
@ -211,9 +212,10 @@ func TestInterpolate_interpolateConnect(t *testing.T) {
LocalServiceAddress: "${address1}", LocalServiceAddress: "${address1}",
LocalServicePort: 10000, LocalServicePort: 10000,
Upstreams: []structs.ConsulUpstream{{ Upstreams: []structs.ConsulUpstream{{
DestinationName: "${destination1}", DestinationName: "${destination1}",
Datacenter: "${datacenter1}", Datacenter: "${datacenter1}",
LocalBindPort: 10001, LocalBindPort: 10001,
LocalBindAddress: "${localbindaddress1}",
}}, }},
Expose: &structs.ConsulExposeConfig{ Expose: &structs.ConsulExposeConfig{
Paths: []structs.ConsulExposePath{{ Paths: []structs.ConsulExposePath{{
@ -318,9 +320,10 @@ func TestInterpolate_interpolateConnect(t *testing.T) {
LocalServiceAddress: "1.2.3.4", LocalServiceAddress: "1.2.3.4",
LocalServicePort: 10000, LocalServicePort: 10000,
Upstreams: []structs.ConsulUpstream{{ Upstreams: []structs.ConsulUpstream{{
DestinationName: "_dest1", DestinationName: "_dest1",
Datacenter: "_datacenter1", Datacenter: "_datacenter1",
LocalBindPort: 10001, LocalBindPort: 10001,
LocalBindAddress: "127.0.0.2",
}}, }},
Expose: &structs.ConsulExposeConfig{ Expose: &structs.ConsulExposeConfig{
Paths: []structs.ConsulExposePath{{ Paths: []structs.ConsulExposePath{{