Skip to content

Commit e309e0a

Browse files
authored
xDS: enable JWT based auth by default (#12471) (#12535)
Signed-off-by: Shashank Ram <[email protected]>
1 parent 6b93bda commit e309e0a

File tree

15 files changed

+399
-81
lines changed

15 files changed

+399
-81
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ SOURCES := $(shell find . -name "*.go" | grep -v test.go)
4242
# ATTENTION: when updating to a new major version of Envoy, check if
4343
# universal header validation has been enabled and if so, we expect
4444
# failures in `test/e2e/header_validation_test.go`.
45-
export ENVOY_IMAGE ?= quay.io/solo-io/envoy-gloo:1.34.6-patch1
45+
export ENVOY_IMAGE ?= quay.io/solo-io/envoy-gloo:1.34.6-patch3
4646
export LDFLAGS := -X 'github.com/kgateway-dev/kgateway/v2/internal/version.Version=$(VERSION)'
4747
export GCFLAGS ?=
4848

api/v1alpha1/shared_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import (
55
gwv1 "sigs.k8s.io/gateway-api/apis/v1"
66
)
77

8+
// Control-plane RBAC rules not specific to policies:
9+
// +kubebuilder:rbac:groups=authentication.k8s.io,resources=tokenreviews,verbs=create
10+
811
// Select the object to attach the policy to.
912
// The object must be in the same namespace as the policy.
1013
// You can target only one object at a time.

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/kgateway-dev/kgateway/v2
22

3-
go 1.24.1
3+
go 1.24.6
44

55
require (
66
github.com/avast/retry-go v2.4.3+incompatible
@@ -24,7 +24,7 @@ require (
2424
github.com/onsi/gomega v1.37.0
2525
github.com/pkg/errors v0.9.1
2626
github.com/rotisserie/eris v0.5.4
27-
github.com/solo-io/envoy-gloo/go v0.0.0-20250102165327-33a74fcf9966
27+
github.com/solo-io/envoy-gloo/go v0.0.0-20251006222822-c8b69090de33
2828
github.com/solo-io/go-list-licenses v0.1.4
2929
github.com/solo-io/go-utils v0.27.3
3030
github.com/spf13/afero v1.12.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,8 +1603,8 @@ github.com/smartystreets/goconvey v1.7.2/go.mod h1:Vw0tHAZW6lzCRk3xgdin6fKYcG+G3
16031603
github.com/smartystreets/goconvey v1.8.1 h1:qGjIddxOk4grTu9JPOU31tVfq3cNdBlNa5sSznIX1xY=
16041604
github.com/smartystreets/goconvey v1.8.1/go.mod h1:+/u4qLyY6x1jReYOp7GOM2FSt8aP9CzCZL03bI28W60=
16051605
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
1606-
github.com/solo-io/envoy-gloo/go v0.0.0-20250102165327-33a74fcf9966 h1:MavIqMAvo9dxhcuN0/m7Ok830e7htfhR+JWRDqs3qj4=
1607-
github.com/solo-io/envoy-gloo/go v0.0.0-20250102165327-33a74fcf9966/go.mod h1:27GcajR+wxZ34COPvLp1+4hxGN66/GSx7SSjVn8LySY=
1606+
github.com/solo-io/envoy-gloo/go v0.0.0-20251006222822-c8b69090de33 h1:UtMr4NEcBhau9fn6I4GWuFF5gDc8+XCZWiUfb4UAKd4=
1607+
github.com/solo-io/envoy-gloo/go v0.0.0-20251006222822-c8b69090de33/go.mod h1:N0bmBwDmmHxKxdosUjjH83+wg5EVJiL2M0X5OqT/ZRk=
16081608
github.com/solo-io/go-list-licenses v0.1.4 h1:u4xh1OUORT4iSWuAp3Q4NsfHcDaeUV8QRDH8ACQqbxw=
16091609
github.com/solo-io/go-list-licenses v0.1.4/go.mod h1:x6LSp/NrYgVXwNum7ZOiaAYTpg6B3F6TrWYfcdHVroA=
16101610
github.com/solo-io/go-utils v0.20.2/go.mod h1:6e8K1spnMWwlnJRSNp/J84GEyJbrcK4Gm7i+ehzCi8c=

install/helm/kgateway/templates/role.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ rules:
6060
- patch
6161
- update
6262
- watch
63+
- apiGroups:
64+
- authentication.k8s.io
65+
resources:
66+
- tokenreviews
67+
verbs:
68+
- create
6369
- apiGroups:
6470
- discovery.k8s.io
6571
resources:

internal/kgateway/extensions2/settings/settings.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ type Settings struct {
4141
DefaultImageTag string `split_words:"true" default:""`
4242
// DefaultImagePullPolicy is the default image pull policy to use for the kgateway image.
4343
DefaultImagePullPolicy string `split_words:"true" default:"IfNotPresent"`
44+
45+
// XdsAuth enables or disables xDS authentication between the data-plane and control-plane.
46+
// By default, this is enabled.
47+
XdsAuth bool `split_words:"true" default:"true"`
4448
}
4549

4650
// BuildSettings returns a zero-valued Settings obj if error is encountered when parsing env

internal/kgateway/extensions2/settings/settings_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func TestSettings(t *testing.T) {
4242
DefaultImageRegistry: "cr.kgateway.dev",
4343
DefaultImageTag: "",
4444
DefaultImagePullPolicy: "IfNotPresent",
45+
XdsAuth: true,
4546
},
4647
},
4748
{
@@ -60,6 +61,7 @@ func TestSettings(t *testing.T) {
6061
"KGW_DEFAULT_IMAGE_REGISTRY": "my-registry",
6162
"KGW_DEFAULT_IMAGE_TAG": "my-tag",
6263
"KGW_DEFAULT_IMAGE_PULL_POLICY": "Always",
64+
"KGW_XDS_AUTH": "false",
6365
},
6466
expectedSettings: &settings.Settings{
6567
DnsLookupFamily: "V4_ONLY",
@@ -74,6 +76,7 @@ func TestSettings(t *testing.T) {
7476
DefaultImageRegistry: "my-registry",
7577
DefaultImageTag: "my-tag",
7678
DefaultImagePullPolicy: "Always",
79+
XdsAuth: false,
7780
},
7881
},
7982
{
@@ -106,6 +109,7 @@ func TestSettings(t *testing.T) {
106109
DefaultImageRegistry: "cr.kgateway.dev",
107110
DefaultImageTag: "",
108111
DefaultImagePullPolicy: "IfNotPresent",
112+
XdsAuth: true,
109113
},
110114
},
111115
}

internal/kgateway/helm/kgateway/templates/gateway/proxy-deployment.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ spec:
6868
volumeMounts:
6969
- mountPath: /etc/envoy
7070
name: envoy-config
71+
- name: xds-token
72+
mountPath: /var/run/secrets/tokens
73+
readOnly: true
74+
{{- with $gateway.extraVolumeMounts }}
75+
{{- toYaml . | nindent 8 }}
76+
{{- end }}
7177
env:
7278
- name: POD_NAME
7379
valueFrom:
@@ -313,6 +319,13 @@ spec:
313319
terminationGracePeriodSeconds: {{ $gateway.terminationGracePeriodSeconds }}
314320
{{- end }}
315321
volumes:
322+
- name: xds-token
323+
projected:
324+
sources:
325+
- serviceAccountToken:
326+
audience: kgateway
327+
expirationSeconds: 43200
328+
path: xds-token
316329
- configMap:
317330
name: {{ include "kgateway.gateway.fullname" . }}
318331
name: envoy-config
@@ -540,6 +553,27 @@ data:
540553
"@type": type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
541554
explicit_http_config:
542555
http2_protocol_options: {}
556+
http_filters:
557+
- name: transform
558+
typed_config:
559+
"@type": type.googleapis.com/envoy.api.v2.filter.http.FilterTransformations
560+
transformations:
561+
- match:
562+
prefix: "/"
563+
route_transformations:
564+
request_transformation:
565+
transformation_template:
566+
headers:
567+
authorization: {"text": 'Bearer {{ "{{ \"{{ trim(data_source(\\\"token\\\")) -}}\" }}" }}'}
568+
passthrough: {}
569+
data_sources:
570+
token:
571+
filename: "/var/run/secrets/tokens/xds-token"
572+
watched_directory:
573+
path: "/var/run/secrets/tokens"
574+
- name: envoy.filters.http.upstream_codec
575+
typed_config:
576+
"@type": type.googleapis.com/envoy.extensions.filters.http.upstream_codec.v3.UpstreamCodec
543577
upstream_connection_options:
544578
tcp_keepalive:
545579
keepalive_time: 10

0 commit comments

Comments
 (0)