Skip to content

Instantly share code, notes, and snippets.

@dnephin
Last active June 4, 2020 20:44
Show Gist options
  • Save dnephin/2fedb709af6f6d33b1153b49691c813c to your computer and use it in GitHub Desktop.
Save dnephin/2fedb709af6f6d33b1153b49691c813c to your computer and use it in GitHub Desktop.
Consul Connect proxy configuration UX
kind = "proxy-defaults"
name = "global"
config {
envoy_statsd_url = "udp://127.0.0.1:8125"
local_connect_timeout_ms = 10000
limits {
max_connections = 200
}
load_balancer {
policy = "ring_hash"
hash_policy {
field = "header"
match_value = "x-my-header"
terminal = "true"
}
hash_policy {
field = "header"
match_value = "x-other-header"
terminal = "true"
}
}
}
{
"kind": "proxy-defaults",
"name": "global",
"config": {
...
}
}
kind = "proxy-defaults"
name = "global"
config = <<EOF
{
"metrics_url": "udp://example.com/metrics:1234",
"settings": {
"sha": "abadfs",
"port": 4444,
}
}
EOF

The following configuration options are valid, but would not be documented, or recommended:

envoy proxy, hcl config, with heredoc for opaque config - we recommend using inline config instead of heredoc for envoy, because the envoy proxy config is only partially opaque. When we finally decode it we can apply the necessary rules to handle the ambiguous HCL decoding. There is no reason to mix hcl+json.

third-party proxy, hcl config, with inline opaque config - we recommend using a heredoc or full JSON config for third-party proxies because decoding a raw HCL structure with structs is not intuitive to most users. If the proxy implementor understands the challenges they are welcome to use this config. We should clearly document the challenges with this approach, so that any third-party proxy implementors understand the trade off. If they are using Go and mapstructure they could re-use our same decode hook and it would be easy enough for them to accept a full inline hcl config as well.

any proxy, json config, with string for opaque config - since we support a string heredoc for HCL, we would also support specifying a string for that field from a JSON config. However there is really no reason to every talk about that option because if the config is JSON, then inline JSON is a lot more natural, and JSON does not have a heredoc, which makes it harder to specify.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment