From ef6bc739a17f368cbab7f7b750bed6958c903a1f Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Fri, 9 Jul 2021 12:48:16 -0400 Subject: [PATCH] config: update config settings and flags for ports.xds --- agent/config/builder.go | 10 ++++++++-- agent/config/config.go | 10 ++++++++-- agent/config/flags.go | 3 ++- agent/config/flags_test.go | 2 +- website/content/docs/agent/options.mdx | 25 ++++++++++++++++++------- 5 files changed, 37 insertions(+), 13 deletions(-) diff --git a/agent/config/builder.go b/agent/config/builder.go index 5fa979dea..530d4495d 100644 --- a/agent/config/builder.go +++ b/agent/config/builder.go @@ -428,7 +428,10 @@ func (b *builder) Build() (rt RuntimeConfig, err error) { httpPort := b.portVal("ports.http", c.Ports.HTTP) httpsPort := b.portVal("ports.https", c.Ports.HTTPS) serverPort := b.portVal("ports.server", c.Ports.Server) - xdsPort := b.portVal("ports.xds", c.Ports.GRPC) + if c.Ports.XDS == nil { + c.Ports.XDS = c.Ports.GRPC + } + xdsPort := b.portVal("ports.xds", c.Ports.XDS) serfPortLAN := b.portVal("ports.serf_lan", c.Ports.SerfLAN) serfPortWAN := b.portVal("ports.serf_wan", c.Ports.SerfWAN) proxyMinPort := b.portVal("ports.proxy_min_port", c.Ports.ProxyMinPort) @@ -555,7 +558,10 @@ func (b *builder) Build() (rt RuntimeConfig, err error) { dnsAddrs := b.makeAddrs(b.expandAddrs("addresses.dns", c.Addresses.DNS), clientAddrs, dnsPort) httpAddrs := b.makeAddrs(b.expandAddrs("addresses.http", c.Addresses.HTTP), clientAddrs, httpPort) httpsAddrs := b.makeAddrs(b.expandAddrs("addresses.https", c.Addresses.HTTPS), clientAddrs, httpsPort) - xdsAddrs := b.makeAddrs(b.expandAddrs("addresses.xds", c.Addresses.GRPC), clientAddrs, xdsPort) + if c.Addresses.XDS == nil { + c.Addresses.XDS = c.Addresses.GRPC + } + xdsAddrs := b.makeAddrs(b.expandAddrs("addresses.xds", c.Addresses.XDS), clientAddrs, xdsPort) for _, a := range dnsAddrs { if x, ok := a.(*net.TCPAddr); ok { diff --git a/agent/config/config.go b/agent/config/config.go index eb11cc356..3dd6c7b45 100644 --- a/agent/config/config.go +++ b/agent/config/config.go @@ -340,7 +340,10 @@ type Addresses struct { DNS *string `mapstructure:"dns"` HTTP *string `mapstructure:"http"` HTTPS *string `mapstructure:"https"` - GRPC *string `mapstructure:"grpc"` + XDS *string `mapstructure:"xds"` + + // Deprecated: replaced by XDS + GRPC *string `mapstructure:"grpc"` } type AdvertiseAddrsConfig struct { @@ -690,13 +693,16 @@ type Ports struct { SerfLAN *int `mapstructure:"serf_lan"` SerfWAN *int `mapstructure:"serf_wan"` Server *int `mapstructure:"server"` - GRPC *int `mapstructure:"grpc"` + XDS *int `mapstructure:"xds"` ProxyMinPort *int `mapstructure:"proxy_min_port"` ProxyMaxPort *int `mapstructure:"proxy_max_port"` SidecarMinPort *int `mapstructure:"sidecar_min_port"` SidecarMaxPort *int `mapstructure:"sidecar_max_port"` ExposeMinPort *int `mapstructure:"expose_min_port"` ExposeMaxPort *int `mapstructure:"expose_max_port"` + + // Deprecated: replaced by XDS + GRPC *int `mapstructure:"grpc"` } type UnixSocket struct { diff --git a/agent/config/flags.go b/agent/config/flags.go index 00deebe1b..0349ad900 100644 --- a/agent/config/flags.go +++ b/agent/config/flags.go @@ -53,7 +53,8 @@ func AddFlags(fs *flag.FlagSet, f *LoadOpts) { add(&f.FlagValues.EnableLocalScriptChecks, "enable-local-script-checks", "Enables health check scripts from configuration file.") add(&f.FlagValues.HTTPConfig.AllowWriteHTTPFrom, "allow-write-http-from", "Only allow write endpoint calls from given network. CIDR format, can be specified multiple times.") add(&f.FlagValues.EncryptKey, "encrypt", "Provides the gossip encryption key.") - add(&f.FlagValues.Ports.GRPC, "grpc-port", "Sets the gRPC API port to listen on (currently needed for Envoy xDS only).") + add(&f.FlagValues.Ports.XDS, "grpc-port", "Deprecated, use xds-port") + add(&f.FlagValues.Ports.XDS, "xds-port", "Sets the xDS gRPC port to listen on (used by Envoy proxies).") add(&f.FlagValues.Ports.HTTP, "http-port", "Sets the HTTP API port to listen on.") add(&f.FlagValues.Ports.HTTPS, "https-port", "Sets the HTTPS API port to listen on.") add(&f.FlagValues.StartJoinAddrsLAN, "join", "Address of an agent to join at start time. Can be specified multiple times.") diff --git a/agent/config/flags_test.go b/agent/config/flags_test.go index 5e1009450..a5c51b7d1 100644 --- a/agent/config/flags_test.go +++ b/agent/config/flags_test.go @@ -49,7 +49,7 @@ func TestAddFlags_WithParse(t *testing.T) { }, { args: []string{`-grpc-port`, `1`}, - expected: LoadOpts{FlagValues: Config{Ports: Ports{GRPC: pInt(1)}}}, + expected: LoadOpts{FlagValues: Config{Ports: Ports{XDS: pInt(1)}}}, }, { args: []string{`-http-port`, `1`}, diff --git a/website/content/docs/agent/options.mdx b/website/content/docs/agent/options.mdx index 04e42a035..ed9bfa292 100644 --- a/website/content/docs/agent/options.mdx +++ b/website/content/docs/agent/options.mdx @@ -242,8 +242,12 @@ The options below are all specified on the command-line. If it is provided after Consul has been initialized with an encryption key, then the provided key is ignored and a warning will be displayed. -- `-grpc-port` ((#\_grpc_port)) - the gRPC API port to listen on. Default - -1 (gRPC disabled). See [ports](#ports) documentation for more detail. +- `-xds-port` - the xDS gRPC port to listen on. Default + -1 (disabled). See [ports](#ports) documentation for more detail. + +- `-grpc-port` ((#\_grpc_port)) - Deprecated, use `-xds-port` instead. + The xDS gRPC port to listen on. Default + -1 (disabled). See [ports](#ports) documentation for more detail. - `-hcl` ((#\_hcl)) - A HCL configuration fragment. This HCL configuration fragment is appended to the configuration and allows to specify the full range @@ -809,7 +813,7 @@ Valid time units are 'ns', 'us' (or 'µs'), 'ms', 's', 'm', 'h'." bind addresses. In Consul 1.0 and later these can be set to a space-separated list of addresses to bind to, or a [go-sockaddr](https://godoc.org/github.com/hashicorp/go-sockaddr/template) template that can potentially resolve to multiple addresses. - `http`, `https` and `grpc` all support binding to a Unix domain socket. A + `http`, `https` and `xds` all support binding to a Unix domain socket. A socket can be specified in the form `unix:///path/to/socket`. A new domain socket will be created at the given path. If the specified file path already exists, Consul will attempt to clear the file and create the domain socket @@ -830,7 +834,8 @@ Valid time units are 'ns', 'us' (or 'µs'), 'ms', 's', 'm', 'h'." - `dns` - The DNS server. Defaults to `client_addr` - `http` - The HTTP API. Defaults to `client_addr` - `https` - The HTTPS API. Defaults to `client_addr` - - `grpc` - The gRPC API. Defaults to `client_addr` + - `xds` - The xDS gRPC API. Defaults to `client_addr` + - `grpc` - Deprecated: use `xds` instead. The xDS gRPC API. Defaults to `client_addr` - `advertise_addr` Equivalent to the [`-advertise` command-line flag](#_advertise). @@ -1721,10 +1726,16 @@ bind_addr = "{{ GetPrivateInterfaces | include \"network\" \"10.0.0.0/8\" | attr - `https` ((#https_port)) - The HTTPS API, -1 to disable. Default -1 (disabled). **We recommend using `8501`** for `https` by convention as some tooling will work automatically with this. - - `grpc` ((#grpc_port)) - The gRPC API, -1 to disable. Default -1 (disabled). - **We recommend using `8502`** for `grpc` by convention as some tooling will work + - `xds` - The xDS gRPC API, -1 to disable. Default -1 (disabled). + **We recommend using `8502`** for `xds` by convention as some tooling will work automatically with this. This is set to `8502` by default when the agent runs - in `-dev` mode. Currently gRPC is only used to expose Envoy xDS API to Envoy + in `-dev` mode. Currently xDS is only used to expose Envoy xDS API to Envoy + proxies. + - `grpc` ((#grpc_port)) - Deprecated: use `xds` instead. + The xDS gRPC API, -1 to disable. Default -1 (disabled). + **We recommend using `8502`** for `xds` by convention as some tooling will work + automatically with this. This is set to `8502` by default when the agent runs + in `-dev` mode. Currently xDS is only used to expose Envoy xDS API to Envoy proxies. - `serf_lan` ((#serf_lan_port)) - The Serf LAN port. Default 8301. TCP and UDP. Equivalent to the [`-serf-lan-port` command line flag](#_serf_lan_port).