Skip to content

Commit

Permalink
use envoyproxy instead of ctp
Browse files Browse the repository at this point in the history
Signed-off-by: Guy Daich <[email protected]>
  • Loading branch information
guydc committed Jan 2, 2025
1 parent 46a40aa commit 32ae4cf
Show file tree
Hide file tree
Showing 17 changed files with 86 additions and 363 deletions.
7 changes: 0 additions & 7 deletions api/v1alpha1/clienttrafficpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,6 @@ type ClientTrafficPolicySpec struct {
//
// +optional
HealthCheck *HealthCheckSettings `json:"healthCheck,omitempty"`
// PreserveRouteOrder determines if the order of matching for HTTPRoutes is determined by Gateway-API
// specification (https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io/v1.HTTPRouteRule)
// or preserves the order defined by users in the HTTPRoute's HTTPRouteRule list.
// Default: False
//
// +optional
PreserveRouteOrder *bool `json:"preserveRouteOrder,omitempty"`
}

// HeaderSettings provides configuration options for headers on the listener.
Expand Down
8 changes: 8 additions & 0 deletions api/v1alpha1/envoyproxy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@ type EnvoyProxySpec struct {
// +kubebuilder:validation:Enum=IPv4;IPv6;DualStack
// +optional
IPFamily *IPFamily `json:"ipFamily,omitempty"`

// PreserveRouteOrder determines if the order of matching for HTTPRoutes is determined by Gateway-API
// specification (https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io/v1.HTTPRouteRule)
// or preserves the order defined by users in the HTTPRoute's HTTPRouteRule list.
// Default: False
//
// +optional
PreserveRouteOrder *bool `json:"preserveRouteOrder,omitempty"`
}

// RoutingType defines the type of routing of this Envoy proxy.
Expand Down
10 changes: 5 additions & 5 deletions api/v1alpha1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -489,13 +489,6 @@ spec:
- UnescapeAndRedirect
type: string
type: object
preserveRouteOrder:
description: |-
PreserveRouteOrder determines if the order of matching for HTTPRoutes is determined by Gateway-API
specification (https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io/v1.HTTPRouteRule)
or preserves the order defined by users in the HTTPRoute's HTTPRouteRule list.
Default: False
type: boolean
targetRef:
description: |-
TargetRef is the name of the resource this policy is being attached to.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,13 @@ spec:
This means that the port, protocol and hostname tuple must be unique for every listener.
If a duplicate listener is detected, the newer listener (based on timestamp) will be rejected and its status will be updated with a "Accepted=False" condition.
type: boolean
preserveRouteOrder:
description: |-
PreserveRouteOrder determines if the order of matching for HTTPRoutes is determined by Gateway-API
specification (https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io/v1.HTTPRouteRule)
or preserves the order defined by users in the HTTPRoute's HTTPRouteRule list.
Default: False
type: boolean
provider:
description: |-
Provider defines the desired resource provider and provider-specific configuration.
Expand Down
4 changes: 0 additions & 4 deletions internal/gatewayapi/clienttrafficpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,10 +482,6 @@ func (t *Translator) translateClientTrafficPolicyForListener(policy *egv1a1.Clie
errs = errors.Join(errs, err)
}

if policy.Spec.PreserveRouteOrder != nil && *policy.Spec.PreserveRouteOrder {
httpIR.PreserverRouteOrder = true
}

// Early return if got any errors
if errs != nil {
return errs
Expand Down
8 changes: 8 additions & 0 deletions internal/gatewayapi/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -663,3 +663,11 @@ func getEnvoyIPFamily(envoyProxy *egv1a1.EnvoyProxy) *egv1a1.IPFamily {
return nil
}
}

// getPreserveRouteOrder returns true if route order should be preserved according to EnvoyProxy spec
func getPreserveRouteOrder(envoyProxy *egv1a1.EnvoyProxy) bool {
if envoyProxy != nil && envoyProxy.Spec.PreserveRouteOrder != nil && *envoyProxy.Spec.PreserveRouteOrder {
return true
}
return false
}
1 change: 1 addition & 0 deletions internal/gatewayapi/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ func (t *Translator) ProcessListeners(gateways []*GatewayContext, xdsIR resource
// see more https://gateway-api.sigs.k8s.io/references/spec/#gateway.networking.k8s.io/gwapiv1.Listener.
irListener.Hostnames = append(irListener.Hostnames, "*")
}
irListener.PreserveRouteOrder = getPreserveRouteOrder(gateway.envoyProxy)
xdsIR[irKey].HTTP = append(xdsIR[irKey].HTTP, irListener)
case gwapiv1.TCPProtocolType, gwapiv1.TLSProtocolType:
irListener := &ir.TCPListener{
Expand Down
2 changes: 1 addition & 1 deletion internal/gatewayapi/sort.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (x XdsIRRoutes) Less(i, j int) bool {
func sortXdsIRMap(xdsIR resource.XdsIRMap) {
for _, irItem := range xdsIR {
for _, http := range irItem.HTTP {
if !http.PreserverRouteOrder {
if !http.PreserveRouteOrder {
// descending order
sort.Sort(sort.Reverse(XdsIRRoutes(http.Routes)))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,11 @@
clientTrafficPolicies:
- apiVersion: gateway.envoyproxy.io/v1alpha1
kind: ClientTrafficPolicy
envoyProxyForGatewayClass:
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: EnvoyProxy
metadata:
namespace: envoy-gateway
name: target-gateway-1
spec:
preserveRouteOrder: false
targetRef:
group: gateway.networking.k8s.io
kind: Gateway
name: gateway-1
- apiVersion: gateway.envoyproxy.io/v1alpha1
kind: ClientTrafficPolicy
metadata:
namespace: envoy-gateway
name: target-gateway-1-section-http-1
namespace: envoy-gateway-system
name: test
spec:
preserveRouteOrder: true
targetRef:
group: gateway.networking.k8s.io
kind: Gateway
name: gateway-1
sectionName: http-preserve-order
gateways:
- apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
Expand All @@ -37,12 +21,6 @@ gateways:
allowedRoutes:
namespaces:
from: All
- name: http-2
protocol: HTTP
port: 8080
allowedRoutes:
namespaces:
from: All
httpRoutes:
- apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
Expand Down
Loading

0 comments on commit 32ae4cf

Please sign in to comment.