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: interpolate task env in config values #14445

Merged
merged 3 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/14445.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
consul: Allow interpolation of task environment values into Consul Service Mesh configuration
```
7 changes: 6 additions & 1 deletion client/taskenv/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ func interpolateMapStringInterface(taskEnv *TaskEnv, orig map[string]interface{}

m := make(map[string]interface{}, len(orig))
for k, v := range orig {
m[taskEnv.ReplaceEnv(k)] = v
envK := taskEnv.ReplaceEnv(k)
if vStr, ok := v.(string); ok {
m[envK] = taskEnv.ReplaceEnv(vStr)
} else {
m[envK] = v
}
}
return m
}
Expand Down
2 changes: 2 additions & 0 deletions client/taskenv/services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ func TestInterpolate_interpolateConnect(t *testing.T) {
},
Config: map[string]interface{}{
"${config1}": 1,
"port": "${port1}",
},
},
},
Expand Down Expand Up @@ -347,6 +348,7 @@ func TestInterpolate_interpolateConnect(t *testing.T) {
},
Config: map[string]interface{}{
"_config1": 1,
"port": "12345",
},
},
},
Expand Down
12 changes: 7 additions & 5 deletions website/content/docs/job-specification/gateway.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ envoy_gateway_bind_addresses "<service>" {
This option applies to terminating gateways that route to services addressed by a
hostname.
- `config` `(map: nil)` - Escape hatch for [Advanced Configuration] of Envoy.
Keys and values support [runtime variable interpolation][interpolation].

#### `address` Parameters

Expand All @@ -98,18 +99,18 @@ envoy_gateway_bind_addresses "<service>" {
on the gateway. If TLS is enabled, then each host defined in the `host` field will
be added as a DNSSAN to the gateway's x509 certificate.

- `tls_min_version` `(string: optional)` - Set the default minimum TLS version
- `tls_min_version` `(string: optional)` - Set the default minimum TLS version
supported by the gateway. Refer to
[`TLSMinVersion`](https://www.consul.io/docs/connect/config-entries/ingress-gateway#tlsminversion)
in the Consul documentation for supported versions.

- `tls_max_version` `(string: optional)` - Set the default maximum TLS version
supported by the gateway. Refer to
- `tls_max_version` `(string: optional)` - Set the default maximum TLS version
supported by the gateway. Refer to
[`TLSMaxVersion`](https://www.consul.io/docs/connect/config-entries/ingress-gateway#tlsmaxversion)
in the Consul documentation for supported versions.

- `cipher_suites` `(array<string>: optional)` - Set the default list of TLS
cipher suites for the gateway's listeners. Refer to
- `cipher_suites` `(array<string>: optional)` - Set the default list of TLS
cipher suites for the gateway's listeners. Refer to
[`CipherSuites`](https://www.consul.io/docs/connect/config-entries/ingress-gateway#ciphersuites)
in the Consul documentation for the supported cipher suites.

Expand Down Expand Up @@ -655,6 +656,7 @@ job "countdash-mesh-two" {
[proxy]: /docs/job-specification/gateway#proxy-parameters
[linked-service]: /docs/job-specification/gateway#service-parameters-1
[listener]: /docs/job-specification/gateway#listener-parameters
[interpolation]: /docs/runtime/interpolation
[service]: /docs/job-specification/gateway#service-parameters
[service-default]: https://www.consul.io/docs/agent/config-entries/service-defaults
[sidecar_task]: /docs/job-specification/sidecar_task
Expand Down
2 changes: 1 addition & 1 deletion website/content/docs/job-specification/proxy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ job "countdash" {
- `config` `(map: nil)` - Proxy configuration that's opaque to Nomad and
passed directly to Consul. See [Consul Connect's
documentation](https://www.consul.io/docs/connect/proxies/envoy#dynamic-configuration)
for details.
for details. Keys and values support [runtime variable interpolation][interpolation].

## `proxy` Examples

Expand Down
1 change: 1 addition & 0 deletions website/content/docs/job-specification/sidecar_task.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ meta.connect.sidecar_image = custom/envoy-${NOMAD_envoy_version}:latest
to the same user the Nomad client is being run as.

- `config` `(map: nil)` - Configuration provided to the driver for initialization.
Keys and values support [runtime variable interpolation][interpolation].

- `env` `(map: nil)` - Map of environment variables used by the driver.

Expand Down