Skip to content

Commit f34e64c

Browse files
authored
Merge branch 'main' into feat/startup-probe-gtw
2 parents ab43efa + 6578a6d commit f34e64c

59 files changed

Lines changed: 1211 additions & 379 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/codeql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ jobs:
3636
- uses: ./tools/github-actions/setup-deps
3737

3838
- name: Initialize CodeQL
39-
uses: github/codeql-action/init@87557b9c84dde89fdd9b10e88954ac2f4248e463 # v3.29.5
39+
uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v3.29.5
4040
with:
4141
languages: ${{ matrix.language }}
4242

4343
- name: Autobuild
44-
uses: github/codeql-action/autobuild@87557b9c84dde89fdd9b10e88954ac2f4248e463 # v3.29.5
44+
uses: github/codeql-action/autobuild@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v3.29.5
4545

4646
- name: Perform CodeQL Analysis
47-
uses: github/codeql-action/analyze@87557b9c84dde89fdd9b10e88954ac2f4248e463 # v3.29.5
47+
uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v3.29.5
4848
with:
4949
category: "/language:${{matrix.language}}"

.github/workflows/scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ jobs:
4040
retention-days: 5
4141

4242
- name: "Upload to code-scanning"
43-
uses: github/codeql-action/upload-sarif@87557b9c84dde89fdd9b10e88954ac2f4248e463 # v3.29.5
43+
uses: github/codeql-action/upload-sarif@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v3.29.5
4444
with:
4545
sarif_file: results.sarif

api/v1alpha1/backend_types.go

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ type UnixSocket struct {
132132

133133
// BackendSpec describes the desired state of BackendSpec.
134134
// +kubebuilder:validation:XValidation:rule="self.type != 'DynamicResolver' || !has(self.endpoints)",message="DynamicResolver type cannot have endpoints specified"
135+
// +kubebuilder:validation:XValidation:rule="self.type != 'DynamicResolver' || !has(self.tls) || !(has(self.tls.autoSNIFromEndpointHostname) && self.tls.autoSNIFromEndpointHostname)",message="DynamicResolver type cannot use autoSNIFromEndpointHostname"
136+
// +kubebuilder:validation:XValidation:rule="!has(self.tls) || !(has(self.tls.autoSNIFromEndpointHostname) && self.tls.autoSNIFromEndpointHostname) || self.endpoints.all(e, (!has(e.ip) && !has(e.unix)) || has(e.hostname))",message="when autoSNIFromEndpointHostname is enabled, IP and Unix endpoints must define a hostname"
135137
type BackendSpec struct {
136138
// Type defines the type of the backend. Defaults to "Endpoints"
137139
//
@@ -173,6 +175,7 @@ type BackendSpec struct {
173175
// BackendTLSSettings holds the TLS settings for the backend.
174176
// +kubebuilder:validation:XValidation:message="must not contain both CACertificateRefs and WellKnownCACertificates",rule="!(has(self.caCertificateRefs) && size(self.caCertificateRefs) > 0 && has(self.wellKnownCACertificates) && self.wellKnownCACertificates != \"\")"
175177
// +kubebuilder:validation:XValidation:message="must not contain either CACertificateRefs or WellKnownCACertificates when InsecureSkipVerify is enabled",rule="!((has(self.insecureSkipVerify) && self.insecureSkipVerify) && ((has(self.caCertificateRefs) && size(self.caCertificateRefs) > 0) || (has(self.wellKnownCACertificates) && self.wellKnownCACertificates != \"\")))"
178+
// +kubebuilder:validation:XValidation:message="sni and autoSNIFromEndpointHostname are mutually exclusive",rule="!(has(self.sni) && has(self.autoSNIFromEndpointHostname) && self.autoSNIFromEndpointHostname)"
176179
type BackendTLSSettings struct {
177180
// CACertificateRefs contains one or more references to Kubernetes objects that
178181
// contain TLS certificates of the Certificate Authorities that can be used
@@ -206,18 +209,32 @@ type BackendTLSSettings struct {
206209
// +optional
207210
InsecureSkipVerify *bool `json:"insecureSkipVerify,omitempty"`
208211

209-
// SNI is specifies the SNI value used when establishing an upstream TLS connection to the backend.
212+
// SNI specifies the fixed SNI value used when establishing an upstream TLS connection to the backend.
210213
//
211214
// Envoy Gateway will use the HTTP host header value for SNI, when all resources referenced in BackendRefs are:
212215
// 1. Backend resources that do not set SNI, or
213216
// 2. Service/ServiceImport resources that do not have a BackendTLSPolicy attached to them
214217
//
215-
// When a BackendTLSPolicy attaches to a Backend resource, the BackendTLSPolicy's Hostname value takes precedence
216-
// over this value.
218+
// If a BackendTLSPolicy is attached to the Backend resource, the BackendTLSPolicy's validation.hostname
219+
// value takes precedence over this field.
220+
//
221+
// If no BackendTLSPolicy validation.hostname applies and both this field and AutoSNIFromEndpointHostname
222+
// are unset, Envoy Gateway configures Envoy to set the upstream SNI from the downstream HTTP host/authority header.
217223
//
218224
// +optional
219225
SNI *gwapiv1.PreciseHostname `json:"sni,omitempty"`
220226

227+
// AutoSNIFromEndpointHostname indicates whether the upstream endpoint's hostname should be used as the SNI value
228+
// when establishing a TLS connection to the backend.
229+
// This uses the resolved hostname of the upstream endpoint (e.g., from the Backend Endpoints list),
230+
// rather than a static value.
231+
//
232+
// Mutually exclusive with SNI. When a BackendTLSPolicy is attached, its Hostname value takes
233+
// precedence and AutoSNIFromEndpointHostname is ignored.
234+
//
235+
// +optional
236+
AutoSNIFromEndpointHostname *bool `json:"autoSNIFromEndpointHostname,omitempty"`
237+
221238
// BackendTLSConfig defines the client certificate/key as well as TLS protocol parameters such as ciphers, TLS versions,
222239
// and ALPN that the Envoy uses when connecting to the backend.
223240
// When omitted, Envoy will fall back to the EnvoyProxy BackendTLS defaults, if any.

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/gateway-crds-helm/templates/generated/gateway.envoyproxy.io_backends.yaml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,16 @@ spec:
189189
using ALPN
190190
type: string
191191
type: array
192+
autoSNIFromEndpointHostname:
193+
description: |-
194+
AutoSNIFromEndpointHostname indicates whether the upstream endpoint's hostname should be used as the SNI value
195+
when establishing a TLS connection to the backend.
196+
This uses the resolved hostname of the upstream endpoint (e.g., from the Backend Endpoints list),
197+
rather than a static value.
198+
199+
Mutually exclusive with SNI. When a BackendTLSPolicy is attached, its Hostname value takes
200+
precedence and AutoSNIFromEndpointHostname is ignored.
201+
type: boolean
192202
caCertificateRefs:
193203
description: |-
194204
CACertificateRefs contains one or more references to Kubernetes objects that
@@ -401,14 +411,17 @@ spec:
401411
type: array
402412
sni:
403413
description: |-
404-
SNI is specifies the SNI value used when establishing an upstream TLS connection to the backend.
414+
SNI specifies the fixed SNI value used when establishing an upstream TLS connection to the backend.
405415
406416
Envoy Gateway will use the HTTP host header value for SNI, when all resources referenced in BackendRefs are:
407417
1. Backend resources that do not set SNI, or
408418
2. Service/ServiceImport resources that do not have a BackendTLSPolicy attached to them
409419
410-
When a BackendTLSPolicy attaches to a Backend resource, the BackendTLSPolicy's Hostname value takes precedence
411-
over this value.
420+
If a BackendTLSPolicy is attached to the Backend resource, the BackendTLSPolicy's validation.hostname
421+
value takes precedence over this field.
422+
423+
If no BackendTLSPolicy validation.hostname applies and both this field and AutoSNIFromEndpointHostname
424+
are unset, Envoy Gateway configures Envoy to set the upstream SNI from the downstream HTTP host/authority header.
412425
maxLength: 253
413426
minLength: 1
414427
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
@@ -437,6 +450,9 @@ spec:
437450
&& ((has(self.caCertificateRefs) && size(self.caCertificateRefs)
438451
> 0) || (has(self.wellKnownCACertificates) && self.wellKnownCACertificates
439452
!= "")))'
453+
- message: sni and autoSNIFromEndpointHostname are mutually exclusive
454+
rule: '!(has(self.sni) && has(self.autoSNIFromEndpointHostname)
455+
&& self.autoSNIFromEndpointHostname)'
440456
- message: setting ciphers has no effect if the minimum possible TLS
441457
version is 1.3
442458
rule: 'has(self.minVersion) && self.minVersion == ''1.3'' ? !has(self.ciphers)
@@ -457,6 +473,14 @@ spec:
457473
x-kubernetes-validations:
458474
- message: DynamicResolver type cannot have endpoints specified
459475
rule: self.type != 'DynamicResolver' || !has(self.endpoints)
476+
- message: DynamicResolver type cannot use autoSNIFromEndpointHostname
477+
rule: self.type != 'DynamicResolver' || !has(self.tls) || !(has(self.tls.autoSNIFromEndpointHostname)
478+
&& self.tls.autoSNIFromEndpointHostname)
479+
- message: when autoSNIFromEndpointHostname is enabled, IP and Unix endpoints
480+
must define a hostname
481+
rule: '!has(self.tls) || !(has(self.tls.autoSNIFromEndpointHostname)
482+
&& self.tls.autoSNIFromEndpointHostname) || self.endpoints.all(e,
483+
(!has(e.ip) && !has(e.unix)) || has(e.hostname))'
460484
status:
461485
description: Status defines the current status of Backend.
462486
properties:

charts/gateway-helm/charts/crds/crds/generated/gateway.envoyproxy.io_backends.yaml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,16 @@ spec:
188188
using ALPN
189189
type: string
190190
type: array
191+
autoSNIFromEndpointHostname:
192+
description: |-
193+
AutoSNIFromEndpointHostname indicates whether the upstream endpoint's hostname should be used as the SNI value
194+
when establishing a TLS connection to the backend.
195+
This uses the resolved hostname of the upstream endpoint (e.g., from the Backend Endpoints list),
196+
rather than a static value.
197+
198+
Mutually exclusive with SNI. When a BackendTLSPolicy is attached, its Hostname value takes
199+
precedence and AutoSNIFromEndpointHostname is ignored.
200+
type: boolean
191201
caCertificateRefs:
192202
description: |-
193203
CACertificateRefs contains one or more references to Kubernetes objects that
@@ -400,14 +410,17 @@ spec:
400410
type: array
401411
sni:
402412
description: |-
403-
SNI is specifies the SNI value used when establishing an upstream TLS connection to the backend.
413+
SNI specifies the fixed SNI value used when establishing an upstream TLS connection to the backend.
404414
405415
Envoy Gateway will use the HTTP host header value for SNI, when all resources referenced in BackendRefs are:
406416
1. Backend resources that do not set SNI, or
407417
2. Service/ServiceImport resources that do not have a BackendTLSPolicy attached to them
408418
409-
When a BackendTLSPolicy attaches to a Backend resource, the BackendTLSPolicy's Hostname value takes precedence
410-
over this value.
419+
If a BackendTLSPolicy is attached to the Backend resource, the BackendTLSPolicy's validation.hostname
420+
value takes precedence over this field.
421+
422+
If no BackendTLSPolicy validation.hostname applies and both this field and AutoSNIFromEndpointHostname
423+
are unset, Envoy Gateway configures Envoy to set the upstream SNI from the downstream HTTP host/authority header.
411424
maxLength: 253
412425
minLength: 1
413426
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
@@ -436,6 +449,9 @@ spec:
436449
&& ((has(self.caCertificateRefs) && size(self.caCertificateRefs)
437450
> 0) || (has(self.wellKnownCACertificates) && self.wellKnownCACertificates
438451
!= "")))'
452+
- message: sni and autoSNIFromEndpointHostname are mutually exclusive
453+
rule: '!(has(self.sni) && has(self.autoSNIFromEndpointHostname)
454+
&& self.autoSNIFromEndpointHostname)'
439455
- message: setting ciphers has no effect if the minimum possible TLS
440456
version is 1.3
441457
rule: 'has(self.minVersion) && self.minVersion == ''1.3'' ? !has(self.ciphers)
@@ -456,6 +472,14 @@ spec:
456472
x-kubernetes-validations:
457473
- message: DynamicResolver type cannot have endpoints specified
458474
rule: self.type != 'DynamicResolver' || !has(self.endpoints)
475+
- message: DynamicResolver type cannot use autoSNIFromEndpointHostname
476+
rule: self.type != 'DynamicResolver' || !has(self.tls) || !(has(self.tls.autoSNIFromEndpointHostname)
477+
&& self.tls.autoSNIFromEndpointHostname)
478+
- message: when autoSNIFromEndpointHostname is enabled, IP and Unix endpoints
479+
must define a hostname
480+
rule: '!has(self.tls) || !(has(self.tls.autoSNIFromEndpointHostname)
481+
&& self.tls.autoSNIFromEndpointHostname) || self.endpoints.all(e,
482+
(!has(e.ip) && !has(e.unix)) || has(e.hostname))'
459483
status:
460484
description: Status defines the current status of Backend.
461485
properties:

internal/gatewayapi/backendtlspolicy.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,9 @@ func mergeServerValidationTLSConfigs(
184184
if btpValidationTLSConfig.CACertificate != nil {
185185
mergedConfig.CACertificate = btpValidationTLSConfig.CACertificate
186186
}
187-
if btpValidationTLSConfig.SNI != nil {
187+
if btpValidationTLSConfig.SNI != nil { // BTP takes precedence for SNI, if set, it will override Backend resource SNI and disable AutoSNIFromEndpointHostname
188188
mergedConfig.SNI = btpValidationTLSConfig.SNI
189+
mergedConfig.AutoSNIFromEndpointHostname = false
189190
}
190191
if btpValidationTLSConfig.UseSystemTrustStore {
191192
mergedConfig.UseSystemTrustStore = btpValidationTLSConfig.UseSystemTrustStore
@@ -255,7 +256,8 @@ func (t *Translator) processServerValidationTLSSettings(
255256
backend *egv1a1.Backend,
256257
) (*ir.TLSUpstreamConfig, error) {
257258
tlsConfig := &ir.TLSUpstreamConfig{
258-
InsecureSkipVerify: ptr.Deref(backend.Spec.TLS.InsecureSkipVerify, false),
259+
InsecureSkipVerify: ptr.Deref(backend.Spec.TLS.InsecureSkipVerify, false),
260+
AutoSNIFromEndpointHostname: ptr.Deref(backend.Spec.TLS.AutoSNIFromEndpointHostname, false),
259261
}
260262

261263
if backend.Spec.TLS.SNI != nil {

internal/gatewayapi/helpers.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -203,17 +203,6 @@ func isRefToListenerSet(parentRef gwapiv1.ParentReference) bool {
203203
return false
204204
}
205205

206-
// HasReadyListener returns true if at least one Listener in the
207-
// provided list has a condition of "Ready: true", and false otherwise.
208-
func HasReadyListener(listeners []*ListenerContext) bool {
209-
for _, listener := range listeners {
210-
if listener.IsReady() {
211-
return true
212-
}
213-
}
214-
return false
215-
}
216-
217206
// ValidateHTTPRouteFilter validates the provided filter within HTTPRoute.
218207
func ValidateHTTPRouteFilter(filter *gwapiv1.HTTPRouteFilter, extGKs ...schema.GroupKind) error {
219208
switch {

internal/gatewayapi/route.go

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,11 +1625,11 @@ func (t *Translator) processUDPRouteParentRefs(udpRoute *UDPRouteContext, resour
16251625
if listener.AttachedRoutes() >= 1 {
16261626
continue
16271627
}
1628+
accepted = true
16281629
listener.IncrementAttachedRoutes()
16291630
if !listener.IsReady() {
16301631
continue
16311632
}
1632-
accepted = true
16331633

16341634
irKey := t.getIRKey(listener.gateway.Gateway)
16351635

@@ -1777,12 +1777,11 @@ func (t *Translator) processTCPRouteParentRefs(tcpRoute *TCPRouteContext, resour
17771777
if listener.AttachedRoutes() >= 1 {
17781778
continue
17791779
}
1780+
accepted = true
1781+
listener.IncrementAttachedRoutes()
17801782
if !listener.IsReady() {
17811783
continue
17821784
}
1783-
listener.IncrementAttachedRoutes()
1784-
1785-
accepted = true
17861785
irKey := t.getIRKey(listener.gateway.Gateway)
17871786

17881787
gwXdsIR := xdsIR[irKey]
@@ -2300,19 +2299,6 @@ func (t *Translator) processAllowedListenersForParentRefs(
23002299
}
23012300
parentRefCtx.SetListeners(allowedListeners...)
23022301

2303-
if !HasReadyListener(allowedListeners) {
2304-
routeStatus := GetRouteStatus(routeContext)
2305-
status.SetRouteStatusCondition(routeStatus,
2306-
parentRefCtx.routeParentStatusIdx,
2307-
routeContext.GetGeneration(),
2308-
gwapiv1.RouteConditionAccepted,
2309-
metav1.ConditionFalse,
2310-
"NoReadyListeners",
2311-
"There are no ready listeners for this parent ref",
2312-
)
2313-
continue
2314-
}
2315-
23162302
routeStatus := GetRouteStatus(routeContext)
23172303
status.SetRouteStatusCondition(routeStatus,
23182304
parentRefCtx.routeParentStatusIdx,
@@ -2528,8 +2514,9 @@ func (t *Translator) processBackendDestinationSetting(
25282514
case bep.Unix != nil:
25292515
addrTypeMap[ir.UDS]++
25302516
irde = &ir.DestinationEndpoint{
2531-
Path: new(bep.Unix.Path),
2532-
Zone: bep.Zone,
2517+
Hostname: bep.Hostname,
2518+
Path: new(bep.Unix.Path),
2519+
Zone: bep.Zone,
25332520
}
25342521
}
25352522

0 commit comments

Comments
 (0)