Skip to content

Commit

Permalink
Implemented the Path Settings API
Browse files Browse the repository at this point in the history
Signed-off-by: Lior Okman <lior.okman@sap.com>
  • Loading branch information
liorokman committed Jan 6, 2024
1 parent af0d693 commit df5326a
Show file tree
Hide file tree
Showing 229 changed files with 1,117 additions and 4 deletions.
15 changes: 15 additions & 0 deletions internal/gatewayapi/clienttrafficpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ func (t *Translator) translateClientTrafficPolicyForListener(policySpec *egv1a1.
// Translate Suppress Envoy Headers
translateListenerSuppressEnvoyHeaders(policySpec.SuppressEnvoyHeaders, httpIR)

// Translate Path Settings
translatePathSettings(policySpec.Path, httpIR)

// enable http3 if set and TLS is enabled
if httpIR.TLS != nil && policySpec.HTTP3 != nil {
httpIR.HTTP3 = &ir.HTTP3Settings{}
Expand Down Expand Up @@ -343,6 +346,18 @@ func translateListenerTCPKeepalive(tcpKeepAlive *egv1a1.TCPKeepalive, httpIR *ir
httpIR.TCPKeepalive = irTCPKeepalive
}

func translatePathSettings(pathSettings *egv1a1.PathSettings, httpIR *ir.HTTPListener) {
if pathSettings == nil {
return
}
if pathSettings.DisableMergeSlashes != nil {
httpIR.Path.MergeSlashes = !*pathSettings.DisableMergeSlashes
}
if pathSettings.EscapedSlashesAction != nil {
httpIR.Path.EscapedSlashesAction = ir.PathEscapedSlashAction(*pathSettings.EscapedSlashesAction)
}
}

func translateListenerProxyProtocol(enableProxyProtocol *bool, httpIR *ir.HTTPListener) {
// Return early if not set
if enableProxyProtocol == nil {
Expand Down
4 changes: 4 additions & 0 deletions internal/gatewayapi/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ func (t *Translator) ProcessListeners(gateways []*GatewayContext, xdsIR XdsIRMap
Address: "0.0.0.0",
Port: uint32(containerPort),
TLS: irTLSConfigs(listener.tlsSecrets),
Path: ir.PathSettings{
MergeSlashes: true,
EscapedSlashesAction: ir.UnescapeAndRedirect,
},
}
if listener.Hostname != nil {
irListener.Hostnames = append(irListener.Hostnames, string(*listener.Hostname))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ xdsIR:
- '*'
isHTTP2: false
name: envoy-gateway/gateway-1/http
path:
escapedSlashesAction: UnescapeAndRedirect
mergeSlashes: true
port: 10080
routes:
- backendWeights:
Expand All @@ -372,6 +375,9 @@ xdsIR:
- '*'
isHTTP2: true
name: envoy-gateway/gateway-2/http
path:
escapedSlashesAction: UnescapeAndRedirect
mergeSlashes: true
port: 10080
routes:
- backendWeights:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ xdsIR:
- '*'
isHTTP2: true
name: envoy-gateway/gateway-1/http
path:
escapedSlashesAction: UnescapeAndRedirect
mergeSlashes: true
port: 10080
routes:
- backendWeights:
Expand Down Expand Up @@ -341,6 +344,9 @@ xdsIR:
- '*'
isHTTP2: false
name: envoy-gateway/gateway-2/http
path:
escapedSlashesAction: UnescapeAndRedirect
mergeSlashes: true
port: 10080
routes:
- backendWeights:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ xdsIR:
- '*'
isHTTP2: true
name: envoy-gateway/gateway-1/http
path:
escapedSlashesAction: UnescapeAndRedirect
mergeSlashes: true
port: 10080
routes:
- backendWeights:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ xdsIR:
- '*'
isHTTP2: true
name: envoy-gateway/gateway-1/http
path:
escapedSlashesAction: UnescapeAndRedirect
mergeSlashes: true
port: 10080
routes:
- backendWeights:
Expand Down Expand Up @@ -271,6 +274,9 @@ xdsIR:
- '*'
isHTTP2: false
name: envoy-gateway/gateway-2/http
path:
escapedSlashesAction: UnescapeAndRedirect
mergeSlashes: true
port: 10080
routes:
- backendWeights:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,9 @@ xdsIR:
- '*'
isHTTP2: true
name: envoy-gateway/gateway-1/http
path:
escapedSlashesAction: UnescapeAndRedirect
mergeSlashes: true
port: 10080
routes:
- backendWeights:
Expand Down Expand Up @@ -442,6 +445,9 @@ xdsIR:
- '*'
isHTTP2: false
name: envoy-gateway/gateway-2/http
path:
escapedSlashesAction: UnescapeAndRedirect
mergeSlashes: true
port: 10080
routes:
- backendWeights:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ xdsIR:
- '*'
isHTTP2: true
name: envoy-gateway/gateway-1/http
path:
escapedSlashesAction: UnescapeAndRedirect
mergeSlashes: true
port: 10080
routes:
- backendWeights:
Expand Down Expand Up @@ -351,6 +354,9 @@ xdsIR:
- '*'
isHTTP2: false
name: envoy-gateway/gateway-2/http
path:
escapedSlashesAction: UnescapeAndRedirect
mergeSlashes: true
port: 10080
routes:
- backendWeights:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ xdsIR:
- '*'
isHTTP2: false
name: envoy-gateway/gateway-1/http
path:
escapedSlashesAction: UnescapeAndRedirect
mergeSlashes: true
port: 10080
routes:
- backendWeights:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ xdsIR:
- '*'
isHTTP2: false
name: envoy-gateway/gateway-1/http
path:
escapedSlashesAction: UnescapeAndRedirect
mergeSlashes: true
port: 10080
routes:
- backendWeights:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ xdsIR:
- '*'
isHTTP2: false
name: envoy-gateway/gateway-1/http
path:
escapedSlashesAction: UnescapeAndRedirect
mergeSlashes: true
port: 10080
routes:
- backendWeights:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ xdsIR:
- '*'
isHTTP2: false
name: envoy-gateway/gateway-1/http
path:
escapedSlashesAction: UnescapeAndRedirect
mergeSlashes: true
port: 10080
routes:
- backendWeights:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ xdsIR:
- '*'
isHTTP2: false
name: envoy-gateway/gateway-1/http
path:
escapedSlashesAction: UnescapeAndRedirect
mergeSlashes: true
port: 10080
routes:
- backendWeights:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ xdsIR:
- '*'
isHTTP2: true
name: envoy-gateway/gateway-1/http
path:
escapedSlashesAction: UnescapeAndRedirect
mergeSlashes: true
port: 10080
routes:
- backendWeights:
Expand Down Expand Up @@ -265,6 +268,9 @@ xdsIR:
- '*'
isHTTP2: false
name: envoy-gateway/gateway-2/http
path:
escapedSlashesAction: UnescapeAndRedirect
mergeSlashes: true
port: 10080
routes:
- backendWeights:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ xdsIR:
- '*'
isHTTP2: true
name: envoy-gateway/gateway-1/http
path:
escapedSlashesAction: UnescapeAndRedirect
mergeSlashes: true
port: 10080
routes:
- backendWeights:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ xdsIR:
- '*'
isHTTP2: true
name: envoy-gateway/gateway-1/http
path:
escapedSlashesAction: UnescapeAndRedirect
mergeSlashes: true
port: 10080
routes:
- backendWeights:
Expand Down Expand Up @@ -295,6 +298,9 @@ xdsIR:
- '*'
isHTTP2: false
name: envoy-gateway/gateway-2/http
path:
escapedSlashesAction: UnescapeAndRedirect
mergeSlashes: true
port: 10080
routes:
- backendWeights:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ xdsIR:
- '*'
isHTTP2: false
name: default/gateway-1/http
path:
escapedSlashesAction: UnescapeAndRedirect
mergeSlashes: true
port: 10080
routes:
- backendWeights:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ xdsIR:
http3: {}
isHTTP2: false
name: envoy-gateway/gateway-1/tls
path:
escapedSlashesAction: UnescapeAndRedirect
mergeSlashes: true
port: 10443
routes:
- backendWeights:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
clientTrafficPolicies:
- apiVersion: gateway.envoyproxy.io/v1alpha1
kind: ClientTrafficPolicy
metadata:
namespace: envoy-gateway
name: target-gateway-1
spec:
path:
disableMergeSlashes: true
escapedSlashesAction: KeepUnchanged
targetRef:
group: gateway.networking.k8s.io
kind: Gateway
name: gateway-1
namespace: envoy-gateway
gateways:
- apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
namespace: envoy-gateway
name: gateway-1
spec:
gatewayClassName: envoy-gateway-class
listeners:
- name: http-1
protocol: HTTP
port: 80
allowedRoutes:
namespaces:
from: Same
- name: http-2
protocol: HTTP
port: 8080
allowedRoutes:
namespaces:
from: Same
Loading

0 comments on commit df5326a

Please sign in to comment.