Skip to content

Commit

Permalink
Merge branch 'projectcontour:main' into rollout_feature
Browse files Browse the repository at this point in the history
  • Loading branch information
harshil1973 authored Oct 16, 2023
2 parents 647999d + 62db87e commit 045f121
Show file tree
Hide file tree
Showing 98 changed files with 2,972 additions and 780 deletions.
1 change: 1 addition & 0 deletions .codespell.ignorewords
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ od
als
wit
aks
immediatedly
2 changes: 1 addition & 1 deletion .github/workflows/build_daily.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
env:
GOPROXY: https://proxy.golang.org/
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
GO_VERSION: 1.21.0
GO_VERSION: 1.21.3
jobs:
e2e-envoy-xds:
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build_main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
with:
version: latest
- name: Log in to GHCR
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build_tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
with:
version: latest
- name: Log in to GHCR
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/prbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
env:
GOPROXY: https://proxy.golang.org/
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
GO_VERSION: 1.21.0
GO_VERSION: 1.21.3
jobs:
lint:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
with:
version: latest
- name: Build image
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ IMAGE := $(REGISTRY)/$(PROJECT)
SRCDIRS := ./cmd ./internal ./apis
LOCAL_BOOTSTRAP_CONFIG = localenvoyconfig.yaml
SECURE_LOCAL_BOOTSTRAP_CONFIG = securelocalenvoyconfig.yaml
ENVOY_IMAGE = docker.io/envoyproxy/envoy:v1.27.0
ENVOY_IMAGE = docker.io/envoyproxy/envoy:v1.27.1
GATEWAY_API_VERSION ?= $(shell grep "sigs.k8s.io/gateway-api" go.mod | awk '{print $$2}')

# Used to supply a local Envoy docker container an IP to connect to that is running
Expand Down Expand Up @@ -44,7 +44,7 @@ endif
IMAGE_PLATFORMS ?= linux/amd64,linux/arm64

# Base build image to use.
BUILD_BASE_IMAGE ?= golang:1.21.0
BUILD_BASE_IMAGE ?= golang:1.21.3

# Enable build with CGO.
BUILD_CGO_ENABLED ?= 0
Expand Down
14 changes: 13 additions & 1 deletion apis/projectcontour/v1/httpproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,18 @@ type Route struct {
// +optional
PathRewritePolicy *PathRewritePolicy `json:"pathRewritePolicy,omitempty"`
// The policy for managing request headers during proxying.
//
// You may dynamically rewrite the Host header to be forwarded
// upstream to the content of a request header using
// the below format "%REQ(X-Header-Name)%". If the value of the header
// is empty, it is ignored.
//
// *NOTE: Pay attention to the potential security implications of using this option.
// Provided header must come from trusted source.
//
// **NOTE: The header rewrite is only done while forwarding and has no bearing
// on the routing decision.
//
// +optional
RequestHeadersPolicy *HeadersPolicy `json:"requestHeadersPolicy,omitempty"`
// The policy for managing response headers during proxying.
Expand Down Expand Up @@ -1268,7 +1280,7 @@ type LoadBalancerPolicy struct {
}

// HeadersPolicy defines how headers are managed during forwarding.
// The `Host` header is treated specially and if set in a HTTP response
// The `Host` header is treated specially and if set in a HTTP request
// will be used as the SNI server name when forwarding over TLS. It is an
// error to attempt to set the `Host` header in a HTTP response.
type HeadersPolicy struct {
Expand Down
21 changes: 21 additions & 0 deletions apis/projectcontour/v1alpha1/contourconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,27 @@ type EnvoyListenerConfig struct {
// Single set of options are applied to all listeners.
// +optional
SocketOptions *SocketOptions `json:"socketOptions,omitempty"`

// Defines the limit on number of HTTP requests that Envoy will process from a single
// connection in a single I/O cycle. Requests over this limit are processed in subsequent
// I/O cycles. Can be used as a mitigation for CVE-2023-44487 when abusive traffic is
// detected. Configures the http.max_requests_per_io_cycle Envoy runtime setting. The default
// value when this is not set is no limit.
//
// +kubebuilder:validation:Minimum=1
// +optional
MaxRequestsPerIOCycle *uint32 `json:"maxRequestsPerIOCycle,omitempty"`

// Defines the value for SETTINGS_MAX_CONCURRENT_STREAMS Envoy will advertise in the
// SETTINGS frame in HTTP/2 connections and the limit for concurrent streams allowed
// for a peer on a single HTTP/2 connection. It is recommended to not set this lower
// than 100 but this field can be used to bound resource usage by HTTP/2 connections
// and mitigate attacks like CVE-2023-44487. The default value when this is not set is
// unlimited.
//
// +kubebuilder:validation:Minimum=1
// +optional
HTTP2MaxConcurrentStreams *uint32 `json:"httpMaxConcurrentStreams,omitempty"`
}

// SocketOptions defines configurable socket options for Envoy listeners.
Expand Down
9 changes: 9 additions & 0 deletions apis/projectcontour/v1alpha1/contourdeployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,15 @@ type EnvoySettings struct {
// +kubebuilder:validation:Minimum=0
// +optional
BaseID int32 `json:"baseID,omitempty"`

// OverloadMaxHeapSize defines the maximum heap memory of the envoy controlled by the overload manager.
// When the value is greater than 0, the overload manager is enabled,
// and when envoy reaches 95% of the maximum heap size, it performs a shrink heap operation,
// When it reaches 98% of the maximum heap size, Envoy Will stop accepting requests.
// More info: https://projectcontour.io/docs/main/config/overload-manager/
//
// +optional
OverloadMaxHeapSize uint64 `json:"overloadMaxHeapSize,omitempty"`
}

// WorkloadType is the type of Kubernetes workload to use for a component.
Expand Down
10 changes: 10 additions & 0 deletions apis/projectcontour/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions changelogs/unreleased/5657-shadialtarsha-minor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
## Specific routes can now opt out of the virtual host's global rate limit policy

Setting `rateLimitPolicy.global.disabled` flag to true on a specific route now disables the global rate limit policy inherited from the virtual host for that route.

### Sample Configurations
In the example below, `/foo` route is opted out from the global rate limit policy defined by the virtualhost.
#### httpproxy.yaml
```yaml
apiVersion: projectcontour.io/v1
kind: HTTPProxy
metadata:
name: echo
spec:
virtualhost:
fqdn: local.projectcontour.io
rateLimitPolicy:
global:
descriptors:
- entries:
- remoteAddress: {}
- genericKey:
key: vhost
value: local.projectcontour.io
routes:
- conditions:
- prefix: /
services:
- name: ingress-conformance-echo
port: 80
- conditions:
- prefix: /foo
rateLimitPolicy:
global:
disabled: true
services:
- name: ingress-conformance-echo
port: 80
```
5 changes: 5 additions & 0 deletions changelogs/unreleased/5672-therealak12-minor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Contour now waits for the cache sync before starting the DAG rebuild and XDS server

Before this, we only waited for informer caches to sync but didn't wait for delivering the events to subscribed handlers.
Now contour waits for the initial list of Kubernetes objects to be cached and processed by handlers (using the returned `HasSynced` methods)
and then starts building its DAG and serving XDS.
24 changes: 24 additions & 0 deletions changelogs/unreleased/5678-clayton-gonsalves-minor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## HTTPProxy: Allow Host header rewrite with dynamic headers.

This Change allows the host header to be rewritten on requests using dynamic headers on the only route level.

#### Example
```yaml
apiVersion: projectcontour.io/v1
kind: HTTPProxy
metadata:
name: dynamic-host-header-rewrite
spec:
fqdn: local.projectcontour.io
routes:
- conditions:
- prefix: /
services:
- name: s1
port: 80
- requestHeaderPolicy:
set:
- name: host
value: "%REQ(x-rewrite-header)%"
```
1 change: 1 addition & 0 deletions changelogs/unreleased/5686-izturn-small.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add flags: `--incluster`, `--kubeconfig` for enable run the `gateway-provisioner` in or out of the cluster.
1 change: 1 addition & 0 deletions changelogs/unreleased/5699-yangyy93-small.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Gateway provisioner: Add the `overloadMaxHeapSize` configuration option to contourDeployment to allow adding [overloadManager](https://projectcontour.io/docs/main/config/overload-manager/) configuration when generating envoy's initial configuration file.
1 change: 0 additions & 1 deletion changelogs/unreleased/5731-skriss-small.md

This file was deleted.

15 changes: 15 additions & 0 deletions changelogs/unreleased/5752-davinci26-major.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## Fix bug with algorithm used to sort Envoy regex/prefix path rules

Envoy greedy matches routes and as a result the order route matches are presented to Envoy is important. Contour attempts to produce consistent routing tables so that the most specific route matches are given preference. This is done to facilitate consistency when using HTTPProxy inclusion and provide a uniform user experience for route matching to be inline with Ingress and Gateway API Conformance.

This changes fixes the sorting algorithm used for `Prefix` and `Regex` based path matching. Previously the algorithm lexicographically sorted based on the path match string instead of sorting them based on the length of the `Prefix`|`Regex`. i.e. Longer prefix/regexes will be sorted first in order to give preference to more specific routes, then lexicographic sorting for things of the same length.

Note that for prefix matching, this change is _not_ expected to change the relative ordering of more specific prefixes vs. less specific ones when the more specific prefix match string has the less specific one as a prefix, e.g. `/foo/bar` will continue to sort before `/foo`. However, relative ordering of other combinations of prefix matches may change per the above description.
### How to update safely

Caution is advised if you update Contour and you are operating large routing tables. We advise you to:

1. Deploy a duplicate Contour installation that parses the same CRDs
2. Port-forward to the Envoy admin interface [docs](https://projectcontour.io/docs/v1.3.0/troubleshooting/)
3. Access `http://127.0.0.1:9001/config_dump` and compare the configuration of Envoy. In particular the routes and their order. The prefix routes might be changing in order, so if they are you need to verify that the route matches as expected.

1 change: 1 addition & 0 deletions changelogs/unreleased/5804-skriss-small.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Gateway API: set Listeners' `ResolvedRefs` condition to `true` by default.
1 change: 1 addition & 0 deletions changelogs/unreleased/5821-sunjayBhatia-small.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updates Envoy to v1.27.1. See the [release notes here](https://www.envoyproxy.io/docs/envoy/v1.27.1/version_history/v1.27/v1.27.1).
16 changes: 16 additions & 0 deletions changelogs/unreleased/5827-sunjayBhatia-minor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## Max HTTP requests per IO cycle is configurable as an additional mitigation for HTTP/2 CVE-2023-44487

Envoy v1.27.1 mitigates CVE-2023-44487 with some default runtime settings, however the `http.max_requests_per_io_cycle` does not have a default value.
This change allows configuring this runtime setting via Contour configuration to allow administrators of Contour to prevent abusive connections from starving resources from other valid connections.
The default is left as the existing behavior (no limit) so as not to impact existing valid traffic.

The Contour ConfigMap can be modified similar to the following (and Contour restarted) to set this value:

```
listener:
max-requests-per-io-cycle: 10
```

(Note this can be used in addition to the existing Listener configuration field `listener.max-requests-per-connection` which is used primarily for HTTP/1.1 connections and is an approximate limit for HTTP/2)

See the [Envoy release notes](https://www.envoyproxy.io/docs/envoy/v1.27.1/version_history/v1.27/v1.27.1) for more details.
1 change: 1 addition & 0 deletions changelogs/unreleased/5841-sunjayBhatia-small.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updates to Go 1.21.3. See the [Go release notes](https://go.dev/doc/devel/release#go1.21.minor) for more information.
11 changes: 11 additions & 0 deletions changelogs/unreleased/5850-sunjayBhatia-minor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## HTTP/2 max concurrent streams is configurable

This field can be used to limit the number of concurrent streams Envoy will allow on a single connection from a downstream peer.
It can be used to tune resource usage and as a mitigation for DOS attacks arising from vulnerabilities like CVE-2023-44487.

The Contour ConfigMap can be modified similar to the following (and Contour restarted) to set this value:

```
listener:
http2-max-concurrent-streams: 50
```
28 changes: 24 additions & 4 deletions cmd/contour/gatewayprovisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ import (
"fmt"
"os"

"github.com/alecthomas/kingpin/v2"
"github.com/novln/docker-parser/distribution/reference"
"github.com/projectcontour/contour/internal/k8s"
"github.com/projectcontour/contour/internal/provisioner"
"github.com/projectcontour/contour/internal/provisioner/controller"
"github.com/projectcontour/contour/pkg/config"

"github.com/alecthomas/kingpin/v2"
"github.com/distribution/reference"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
"k8s.io/client-go/rest"
ctrl "sigs.k8s.io/controller-runtime"
Expand All @@ -34,7 +36,7 @@ func registerGatewayProvisioner(app *kingpin.Application) (*kingpin.CmdClause, *

provisionerConfig := &gatewayProvisionerConfig{
contourImage: "ghcr.io/projectcontour/contour:main",
envoyImage: "docker.io/envoyproxy/envoy:v1.27.0",
envoyImage: "docker.io/envoyproxy/envoy:v1.27.1",
metricsBindAddress: ":8080",
leaderElection: false,
leaderElectionID: "0d879e31.projectcontour.io",
Expand All @@ -56,6 +58,13 @@ func registerGatewayProvisioner(app *kingpin.Application) (*kingpin.CmdClause, *
Default(provisionerConfig.gatewayControllerName).
StringVar(&provisionerConfig.gatewayControllerName)

cmd.Flag("incluster", "Use in cluster configuration.").
Default("true").
BoolVar(&provisionerConfig.inCluster)
cmd.Flag("kubeconfig", "Path to kubeconfig (if not in running inside a cluster).").
PlaceHolder("/path/to/file").
StringVar(&provisionerConfig.kubeconfig)

cmd.Flag("leader-election-namespace", "The namespace in which the leader election resource will be created.").
Default(config.GetenvOr("CONTOUR_PROVISIONER_NAMESPACE", "projectcontour")).
StringVar(&provisionerConfig.leaderElectionNamespace)
Expand Down Expand Up @@ -95,6 +104,10 @@ type gatewayProvisionerConfig struct {
// gatewayControllerName defines the controller string that this gateway provisioner instance
// will process GatewayClasses and Gateways for.
gatewayControllerName string

// Kubernetes client parameters.
inCluster bool
kubeconfig string
}

func runGatewayProvisioner(config *gatewayProvisionerConfig) {
Expand All @@ -111,7 +124,14 @@ func runGatewayProvisioner(config *gatewayProvisionerConfig) {
setupLog.Info("using contour", "image", config.contourImage)
setupLog.Info("using envoy", "image", config.envoyImage)

mgr, err := createManager(ctrl.GetConfigOrDie(), config)
// Establish k8s core client connection.
restConfig, err := k8s.NewRestConfig(config.kubeconfig, config.inCluster)
if err != nil {
setupLog.Error(err, "failed to create REST config for Kubernetes clients")
os.Exit(1)
}

mgr, err := createManager(restConfig, config)
if err != nil {
setupLog.Error(err, "failed to create contour gateway provisioner")
os.Exit(1)
Expand Down
Loading

0 comments on commit 045f121

Please sign in to comment.