github.com/projectcontour/contour@v1.28.2/site/content/docs/v1.13.1/configuration.md (about) 1 # Contour Configuration Reference 2 3 - [Serve Flags](#serve-flags) 4 - [Configuration File](#configuration-file) 5 - [Environment Variables](#environment-variables) 6 - [Bootstrap Config File](#bootstrap-config-file) 7 8 ## Overview 9 10 There are various ways to configure Contour, flags, the configuration file, as well as environment variables. 11 Contour has a precedence of configuration for contour serve, meaning anything configured in the config file is overridden by environment vars which are overridden by cli flags. 12 13 ## Serve Flags 14 15 The `contour serve` command is the main command which is used to watch for Kubernetes resource and process them into Envoy configuration which is then streamed to any Envoy via its xDS gRPC connection. 16 There are a number of flags that can be passed to this command which further configures how Contour operates. 17 Many of these flags are mirrored in the [Contour Configuration File](#configuration-file). 18 19 | Flag Name | Description | 20 |-------------------|--------------------| 21 | `--config-path` | Path to base configuration | 22 | `--incluster` | Use in cluster configuration | 23 | `--kubeconfig=</path/to/file>` | Path to kubeconfig (if not in running inside a cluster) | 24 | `--xds-address=<ipaddr>` | xDS gRPC API address | 25 | `--xds-port=<port>` | xDS gRPC API port | 26 | `--stats-address=<ipaddr>` | Envoy /stats interface address | 27 | `--stats-port=<port>` | Envoy /stats interface port | 28 | `--debug-http-address=<address>` | Address the debug http endpoint will bind to. | 29 | `--debug-http-port=<port>` | Port the debug http endpoint will bind to | 30 | `--http-address=<ipaddr>` | Address the metrics HTTP endpoint will bind to | 31 | `--http-port=<port>` | Port the metrics HTTP endpoint will bind to. | 32 | `--health-address=<ipaddr>` | Address the health HTTP endpoint will bind to | 33 | `--health-port=<port>` | Port the health HTTP endpoint will bind to | 34 | `--contour-cafile=</path/to/file\|CONTOUR_CERT_FILE>` | CA bundle file name for serving gRPC with TLS | 35 | `--contour-cert-file=</path/to/file\|CONTOUR_CERT_FILE>` | Contour certificate file name for serving gRPC over TLS | 36 | `--contour-key-file=</path/to/file\|CONTOUR_KEY_FILE>` | Contour key file name for serving gRPC over TLS | 37 | `--insecure` | Allow serving without TLS secured gRPC | 38 | `--root-namespaces=<ns,ns>` | Restrict contour to searching these namespaces for root ingress routes | 39 | `--ingress-class-name=<name>` | Contour IngressClass name | 40 | `--ingress-status-address=<address>` | Address to set in Ingress object status | 41 | `--envoy-http-access-log=</path/to/file>` | Envoy HTTP access log | 42 | `--envoy-https-access-log=</path/to/file>` | Envoy HTTPS access log | 43 | `--envoy-service-http-address=<ipaddr>` | Kubernetes Service address for HTTP requests | 44 | `--envoy-service-https-address=<ipaddr>` | Kubernetes Service address for HTTPS requests | 45 | `--envoy-service-http-port=<port>` | Kubernetes Service port for HTTP requests | 46 | `--envoy-service-https-port=<port>` | Kubernetes Service port for HTTPS requests | 47 | `--envoy-service-name=<name>` | Name of the Envoy service to inspect for Ingress status details. | 48 | `--envoy-service-namespace=<namespace>` | Envoy Service Namespace | 49 | `--use-proxy-protocol` | Use PROXY protocol for all listeners | 50 | `--accesslog-format=<envoy\|json>` | Format for Envoy access logs | 51 | `--disable-leader-election` | Disable leader election mechanism | 52 | `-d, --debug` | Enable debug logging | 53 | `--kubernetes-debug=<log level>` | Enable Kubernetes client debug logging | 54 | `--experimental-service-apis` | DEPRECATED: Please configure the gateway.name & gateway.namespace in the configuration file. | 55 56 57 ## Configuration File 58 59 A configuration file can be passed to the `--config-path` argument of the `contour serve` command to specify additional configuration to Contour. 60 In most deployments, this file is passed to Contour via a ConfigMap which is mounted as a volume to the Contour pod. 61 62 The Contour configuration file is optional. 63 In its absence, Contour will operate with reasonable defaults. 64 Where Contour settings can also be specified with command-line flags, the command-line value takes precedence over the configuration file. 65 66 | Field Name | Type | Default | Description | 67 |------------|------|---------|-------------| 68 | accesslog-format | string | `envoy` | This key sets the global [access log format][2] for Envoy. Valid options are `envoy` or `json`. | 69 | debug | boolean | `false` | Enables debug logging. | 70 | default-http-versions | string array | <code style="white-space:nowrap">HTTP/1.1</code> <br> <code style="white-space:nowrap">HTTP/2</code> | This array specifies the HTTP versions that Contour should program Envoy to serve. HTTP versions are specified as strings of the form "HTTP/x", where "x" represents the version number. | 71 | disableAllowChunkedLength | boolean | `false` | If this field is true, Contour will disable the RFC-compliant Envoy behavior to strip the `Content-Length` header if `Transfer-Encoding: chunked` is also set. This is an emergency off-switch to revert back to Envoy's default behavior in case of failures. | 72 | disablePermitInsecure | boolean | `false` | If this field is true, Contour will ignore `PermitInsecure` field in HTTPProxy documents. | 73 | envoy-service-name | string | `envoy` | This sets the service name that will be inspected for address details to be applied to Ingress objects. | 74 | envoy-service-namespace | string | `projectcontour` | This sets the namespace of the service that will be inspected for address details to be applied to Ingress objects. If the `CONTOUR_NAMESPACE` environment variable is present, Contour will populate this field with its value. | 75 | ingress-status-address | string | None | If present, this specifies the address that will be copied into the Ingress status for each Ingress that Contour manages. It is exclusive with `envoy-service-name` and `envoy-service-namespace`.| 76 | incluster | boolean | `false` | This field specifies that Contour is running in a Kubernetes cluster and should use the in-cluster client access configuration. | 77 | json-fields | string array | [fields][5]| This is the list the field names to include in the JSON [access log format][2]. | 78 | kubeconfig | string | `$HOME/.kube/config` | Path to a Kubernetes [kubeconfig file][3] for when Contour is executed outside a cluster. | 79 | leaderelection | leaderelection | | The [leader election configuration](#leader-election-configuration). | 80 | tls | TLS | | The default [TLS configuration](#tls-configuration). | 81 | timeouts | TimeoutConfig | | The [timeout configuration](#timeout-configuration). | 82 | cluster | ClusterConfig | | The [cluster configuration](#cluster-configuration). | 83 | network | NetworkConfig | | The [network configuration](#network-configuration). | 84 | listener | ListenerConfig | | The [listener configuration](#listener-configuration). | 85 | server | ServerConfig | | The [server configuration](#server-configuration) for `contour serve` command. | 86 | gateway | GatewayConfig | | The [gateway-api Gateway configuration](#gateway-configuration). | 87 | rateLimitService | RateLimitServiceConfig | | The [rate limit service configuration](#rate-limit-service-configuration). | 88 89 90 ### TLS Configuration 91 92 The TLS configuration block can be used to configure default values for how 93 Contour should provision TLS hosts. 94 95 | Field Name | Type| Default | Description | 96 |------------|-----|----------|-------------| 97 | minimum-protocol-version| string | `1.2` | This field specifies the minimum TLS protocol version that is allowed. Valid options are `1.2` (default) and `1.3`. Any other value defaults to TLS 1.2. | 98 | fallback-certificate | | | [Fallback certificate configuration](#fallback-certificate). | 99 | envoy-client-certificate | | | [Client certificate configuration for Envoy](#envoy-client-certificate). | 100 | cipher-suites | []string | See [config package documentation](https://pkg.go.dev/github.com/projectcontour/contour/pkg/config#pkg-variables) | This field specifies the TLS ciphers to be supported by TLS listeners when negotiating TLS 1.2. This parameter should only be used by advanced users. Note that this is ignored when TLS 1.3 is in use. The set of ciphers that are allowed is a superset of those supported by default in stock, non-FIPS Envoy builds and FIPS builds as specified [here](https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/transport_sockets/tls/v3/common.proto#envoy-v3-api-field-extensions-transport-sockets-tls-v3-tlsparameters-cipher-suites). Custom ciphers not accepted by Envoy in a standard build are not supported. | 101 102 103 ### Fallback Certificate 104 105 | Field Name | Type| Default | Description | 106 |------------|-----|----------|-------------| 107 | name | string | `""` | This field specifies the name of the Kubernetes secret to use as the fallback certificate. | 108 | namespace | string | `""` | This field specifies the namespace of the Kubernetes secret to use as the fallback certificate. | 109 110 111 ### Envoy Client Certificate 112 113 | Field Name | Type| Default | Description | 114 |------------|-----|----------|-------------| 115 | name | string | `""` | This field specifies the name of the Kubernetes secret to use as the client certificate and private key when establishing TLS connections to the backend service. | 116 | namespace | string | `""` | This field specifies the namespace of the Kubernetes secret to use as the client certificate and private key when establishing TLS connections to the backend service. | 117 118 119 ### Leader Election Configuration 120 121 The leader election configuration block configures how a deployment with more than one Contour pod elects a leader. 122 The Contour leader is responsible for updating the status field on Ingress and HTTPProxy documents. 123 In the vast majority of deployments, only the `configmap-name` and `configmap-namespace` fields should require any configuration. 124 125 | Field Name | Type | Default | Description | 126 |------------|------|---------|-------------| 127 | configmap-name | string | `leader-elect` | The name of the ConfigMap that Contour leader election will lease. | 128 | configmap-namespace | string | `projectcontour` | The namespace of the ConfigMap that Contour leader election will lease. If the `CONTOUR_NAMESPACE` environment variable is present, Contour will populate this field with its value. | 129 | lease-duration | [duration][4] | `15s` | The duration of the leadership lease. | 130 | renew-deadline | [duration][4] | `10s` | The length of time that the leader will retry refreshing leadership before giving up. | 131 | retry-period | [duration][4] | `2s` | The interval at which Contour will attempt to the acquire leadership lease. | 132 133 134 ### Timeout Configuration 135 136 The timeout configuration block can be used to configure various timeouts for the proxies. All fields are optional; Contour/Envoy defaults apply if a field is not specified. 137 138 | Field Name | Type| Default | Description | 139 |------------|-----|----------|-------------| 140 | request-timeout | string | none* | This field specifies the default request timeout. Note that this is a timeout for the entire request, not an idle timeout. Must be a [valid Go duration string][4], or omitted or set to `infinity` to disable the timeout entirely. See [the Envoy documentation][12] for more information.<br /><br />_Note: A value of `0s` previously disabled this timeout entirely. This is no longer the case. Use `infinity` or omit this field to disable the timeout._ | 141 | connection-idle-timeout| string | `60s` | This field defines how long the proxy should wait while there are no active requests (for HTTP/1.1) or streams (for HTTP/2) before terminating an HTTP connection. Must be a [valid Go duration string][4], or `infinity` to disable the timeout entirely. See [the Envoy documentation][8] for more information. | 142 | stream-idle-timeout| string | `5m`* |This field defines how long the proxy should wait while there is no request activity (for HTTP/1.1) or stream activity (for HTTP/2) before terminating the HTTP request or stream. Must be a [valid Go duration string][4], or `infinity` to disable the timeout entirely. See [the Envoy documentation][9] for more information. | 143 | max-connection-duration | string | none* | This field defines the maximum period of time after an HTTP connection has been established from the client to the proxy before it is closed by the proxy, regardless of whether there has been activity or not. Must be a [valid Go duration string][4], or omitted or set to `infinity` for no max duration. See [the Envoy documentation][10] for more information. | 144 | delayed-close-timeout | string | `1s`* | *Note: this is an advanced setting that should not normally need to be tuned.* <br /><br /> This field defines how long envoy will wait, once connection close processing has been initiated, for the downstream peer to close the connection before Envoy closes the socket associated with the connection. Setting this timeout to 'infinity' will disable it. See [the Envoy documentation][13] for more information. | 145 | connection-shutdown-grace-period | string | `5s`* | This field defines how long the proxy will wait between sending an initial GOAWAY frame and a second, final GOAWAY frame when terminating an HTTP/2 connection. During this grace period, the proxy will continue to respond to new streams. After the final GOAWAY frame has been sent, the proxy will refuse new streams. Must be a [valid Go duration string][4]. See [the Envoy documentation][11] for more information. | 146 147 _* This is Envoy's default setting value and is not explicitly configured by Contour._ 148 149 ### Cluster Configuration 150 151 The cluster configuration block can be used to configure various parameters for Envoy clusters. 152 153 | Field Name | Type| Default | Description | 154 |------------|-----|----------|-------------| 155 | dns-lookup-family | string | auto | This field specifies the dns-lookup-family to use for upstream requests to externalName type Kubernetes services from an HTTPProxy route. Values are: `auto`, `v4, `v6` | 156 157 158 ### Network Configuration 159 160 The network configuration block can be used to configure various parameters network connections. 161 162 | Field Name | Type| Default | Description | 163 |------------|-----|----------|-------------| 164 | num-trusted-hops | int | 0 | Configures the number of additional ingress proxy hops from the right side of the x-forwarded-for HTTP header to trust. | 165 166 167 ### Listener Configuration 168 169 The listener configuration block can be used to configure various parameters for Envoy listener. 170 171 | Field Name | Type| Default | Description | 172 |------------|-----|----------|-------------| 173 | connection-balancer | string | `""` | This field specifies the listener connection balancer. If the value is `exact`, the listener will use the exact connection balancer to balance connections between threads in a single Envoy process. See [the Envoy documentation][14] for more information. | 174 175 176 ### Server Configuration 177 178 The server configuration block can be used to configure various settings for the `contour serve` command. 179 180 | Field Name | Type| Default | Description | 181 |------------|-----|----------|-------------| 182 | xds-server-type | string | contour | This field specifies the xDS Server to use. Options are `contour` or `envoy`. | 183 184 185 ### Gateway Configuration 186 187 The gateway configuration block is used to configure which gateway-api Gateway Contour should configure: 188 189 | Field Name | Type| Default | Description | 190 |------------|-----|----------|-------------| 191 | name | string | contour | This field specifies the name of a Gateway. | 192 | namespace | string | projectcontour | This field specifies the namespace of a Gateway. | 193 194 195 ### Rate Limit Service Configuration 196 197 The rate limit service configuration block is used to configure an optional global rate limit service: 198 199 | Field Name | Type| Default | Description | 200 |------------|-----|----------|-------------| 201 | extensionService | string | <none> | This field identifies the extension service defining the rate limit service, formatted as <namespace>/<name>. | 202 | domain | string | contour | This field defines the rate limit domain value to pass to the rate limit service. Acts as a container for a set of rate limit definitions within the RLS. | 203 | failOpen | bool | false | This field defines whether to allow requests to proceed when the rate limit service fails to respond with a valid rate limit decision within the timeout defined on the extension service. | 204 205 206 ### Configuration Example 207 208 The following is an example ConfigMap with configuration file included: 209 210 ```yaml 211 apiVersion: v1 212 kind: ConfigMap 213 metadata: 214 name: contour 215 namespace: projectcontour 216 data: 217 contour.yaml: | 218 # 219 # server: 220 # determine which XDS Server implementation to utilize in Contour. 221 # xds-server-type: contour 222 # 223 # specify the gateway-api Gateway Contour should configure 224 # gateway: 225 # name: contour 226 # namespace: projectcontour 227 # 228 # should contour expect to be running inside a k8s cluster 229 # incluster: true 230 # 231 # path to kubeconfig (if not running inside a k8s cluster) 232 # kubeconfig: /path/to/.kube/config 233 # 234 # Disable RFC-compliant behavior to strip "Content-Length" header if 235 # "Tranfer-Encoding: chunked" is also set. 236 # disableAllowChunkedLength: false 237 # Disable HTTPProxy permitInsecure field 238 disablePermitInsecure: false 239 tls: 240 # minimum TLS version that Contour will negotiate 241 # minimum-protocol-version: "1.2" 242 # TLS ciphers to be supported by Envoy TLS listeners when negotiating 243 # TLS 1.2. 244 # cipher-suites: 245 # - '[ECDHE-ECDSA-AES128-GCM-SHA256|ECDHE-ECDSA-CHACHA20-POLY1305]' 246 # - '[ECDHE-RSA-AES128-GCM-SHA256|ECDHE-RSA-CHACHA20-POLY1305]' 247 # - 'ECDHE-ECDSA-AES256-GCM-SHA384' 248 # - 'ECDHE-RSA-AES256-GCM-SHA384' 249 # Defines the Kubernetes name/namespace matching a secret to use 250 # as the fallback certificate when requests which don't match the 251 # SNI defined for a vhost. 252 fallback-certificate: 253 # name: fallback-secret-name 254 # namespace: projectcontour 255 envoy-client-certificate: 256 # name: envoy-client-cert-secret-name 257 # namespace: projectcontour 258 # The following config shows the defaults for the leader election. 259 # leaderelection: 260 # configmap-name: leader-elect 261 # configmap-namespace: projectcontour 262 ### Logging options 263 # Default setting 264 accesslog-format: envoy 265 # To enable JSON logging in Envoy 266 # accesslog-format: json 267 # The default fields that will be logged are specified below. 268 # To customise this list, just add or remove entries. 269 # The canonical list is available at 270 # https://godoc.org/github.com/projectcontour/contour/internal/envoy#JSONFields 271 # json-fields: 272 # - "@timestamp" 273 # - "authority" 274 # - "bytes_received" 275 # - "bytes_sent" 276 # - "downstream_local_address" 277 # - "downstream_remote_address" 278 # - "duration" 279 # - "method" 280 # - "path" 281 # - "protocol" 282 # - "request_id" 283 # - "requested_server_name" 284 # - "response_code" 285 # - "response_flags" 286 # - "uber_trace_id" 287 # - "upstream_cluster" 288 # - "upstream_host" 289 # - "upstream_local_address" 290 # - "upstream_service_time" 291 # - "user_agent" 292 # - "x_forwarded_for" 293 # 294 # default-http-versions: 295 # - "HTTP/2" 296 # - "HTTP/1.1" 297 # 298 # The following shows the default proxy timeout settings. 299 # timeouts: 300 # request-timeout: infinity 301 # connection-idle-timeout: 60s 302 # stream-idle-timeout: 5m 303 # max-connection-duration: infinity 304 # connection-shutdown-grace-period: 5s 305 # 306 # Envoy cluster settings. 307 # cluster: 308 # configure the cluster dns lookup family 309 # valid options are: auto (default), v4, v6 310 # dns-lookup-family: auto 311 # 312 # network: 313 # Configure the number of additional ingress proxy hops from the 314 # right side of the x-forwarded-for HTTP header to trust. 315 # num-trusted-hops: 0 316 # 317 # rateLimitService: 318 # extensionService: projectcontour/ratelimit 319 # domain: contour 320 # failOpen: false 321 ``` 322 323 _Note:_ The default example `contour` includes this [file][1] for easy deployment of Contour. 324 325 ## Environment Variables 326 327 ### CONTOUR_NAMESPACE 328 329 If present, the value of the `CONTOUR_NAMESPACE` environment variable is used as: 330 331 1. The value for the `contour bootstrap --namespace` flag unless otherwise specified. 332 1. The value for the `contour certgen --namespace` flag unless otherwise specified. 333 1. The value for the `contour serve --envoy-service-namespace` flag unless otherwise specified. 334 1. The value for the `leaderelection.configmap-namespace` config file setting for `contour serve` unless otherwise specified. 335 336 The `CONTOUR_NAMESPACE` environment variable is set via the [Downward API][6] in the Contour [example manifests][7]. 337 338 ## Bootstrap Config File 339 340 The bootstrap configuration file is generated by an initContainer in the Envoy daemonset which runs the `contour bootstrap` command to generate the file. 341 This configuration file configures the Envoy container to connect to Contour and receive configuration via xDS. 342 343 The next section outlines all the available flags that can be passed to the `contour bootstrap` command which are used to customize 344 the configuration file to match the environment in which Envoy is deployed. 345 346 ### Flags 347 348 There are flags that can be passed to `contour bootstrap` that help configure how Envoy 349 connects to Contour: 350 351 | Flag | Default | Description | 352 |------------|----------|-------------| 353 | <nobr>--resources-dir</nobr> | "" | Directory where resource files will be written. | 354 | <nobr>--admin-address</nobr> | 127.0.0.1 | Address the Envoy admin webpage will listen on. | 355 | <nobr>--admin-port</nobr> | 9001 | Port the Envoy admin webpage will listen on. | 356 | <nobr>--xds-address</nobr> | 127.0.0.1 | Address to connect to Contour xDS server on. | 357 | <nobr>--xds-port</nobr> | 8001 | Port to connect to Contour xDS server on. | 358 | <nobr>--envoy-cafile</nobr> | "" | CA filename for Envoy secure xDS gRPC communication. | 359 | <nobr>--envoy-cert-file</nobr> | "" | Client certificate filename for Envoy secure xDS gRPC communication. | 360 | <nobr>--envoy-key-file</nobr> | "" | Client key filename for Envoy secure xDS gRPC communication. | 361 | <nobr>--namespace</nobr> | projectcontour | Namespace the Envoy container will run, also configured via ENV variable "CONTOUR_NAMESPACE". Namespace is used as part of the metric names on static resources defined in the bootstrap configuration file. | 362 | <nobr>--xds-resource-version</nobr> | v3 | Currently, the only valid xDS API resource version is `v3`. | 363 | <nobr>--dns-lookup-family</nobr> | auto | Defines what DNS Resolution Policy to use for Envoy -> Contour cluster name lookup. Either v4, v6 or auto. | 364 365 366 367 [1]: {{< param github_url >}}/tree/{{< param version >}}/examples/contour/01-contour-config.yaml 368 [2]: /guides/structured-logs 369 [3]: https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/ 370 [4]: https://golang.org/pkg/time/#ParseDuration 371 [5]: https://godoc.org/github.com/projectcontour/contour/internal/envoy#DefaultFields 372 [6]: https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/ 373 [7]: {{< param github_url >}}/tree/{{< param version >}}/examples/contour 374 [8]: https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/core/v3/protocol.proto#envoy-v3-api-field-config-core-v3-httpprotocoloptions-idle-timeout 375 [9]: https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto#envoy-v3-api-field-extensions-filters-network-http-connection-manager-v3-httpconnectionmanager-stream-idle-timeout 376 [10]: https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/core/v3/protocol.proto#envoy-v3-api-field-config-core-v3-httpprotocoloptions-max-connection-duration 377 [11]: https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto#envoy-v3-api-field-extensions-filters-network-http-connection-manager-v3-httpconnectionmanager-drain-timeout 378 [12]: https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto#envoy-v3-api-field-extensions-filters-network-http-connection-manager-v3-httpconnectionmanager-request-timeout 379 [13]: https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto#envoy-v3-api-field-extensions-filters-network-http-connection-manager-v3-httpconnectionmanager-delayed-close-timeout 380 [14]: https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/listener/v3/listener.proto#config-listener-v3-listener-connectionbalanceconfig