Skip to content

Commit

Permalink
GatewayRoute changes
Browse files Browse the repository at this point in the history
Added Test case for gateway_validator

Update to gatewayroute test case

Added matching based on path and query parameters in Route CRD

Added path rewrite changes to Gateway Route CRDs

Updated
1. gatewayroute_type and virtualrouter_type changes
2. CRD conversion Changes for gatewayroute and virtualrouter
3. Validator changes for gatewayroute

Added Rewrite changes to GatewayRoute CRD
Added Conversion code for CRD to SDK
Added Validation logic for Rewrite
Added Validation Tests
Added Conversion Tests

Fixed race condition test (aws#457)

Fixed typos in comments (aws#461)

Updated LiveDocs for VGW section (aws#454)

Update docs for vgw  (aws#467)

* Updated LiveDocs for sidecar Injection in VGW section

* Added a new section for VGW CRD in LiveDocs reference

* Updated Docs to explain the association of VGW and GWRoutes

* Updated Live Docs for VGW

* minor change

Co-authored-by: Chinmay Gadgil <cgadgil@amazon.com>

Added a new GatewayRoute selector optional field to VirtualGateway (aws#464)

* Added a new GatewayRoute selector optional field to VirtualGateway
Updated membership_designator logic for GatewayRoute to VirtualGateway

* Select only those virtualGateways which have matching gatewayRoute selector if specified

* Updated Logic for GatewayRoute Selector

* Updated logic in membership_designator and added test cases

* Addressed PR comments

* Updated error Message to include gatewayroute name if we cannot find any matching virtualgateways.

* Updated CRD for VirtualGateway

* Undo crd changes as these must be sent to a preview branch for 1.4.0 release

* Added VGW CRD changes

Co-authored-by: Chinmay Gadgil <cgadgil@amazon.com>

Update jaegar tracing Envoy config to v3 API (aws#468)

Added validation logic
Updated Test files
Changes tested with gamma endpoint

Use camel casing for field names instead of underscores

reverted go.mod changes

Updated CRD's , fixed naming

revert go.sum changes

Changes to troubleshooting guide

Changed HTTPathMatch to a pointer in HTTPRouteMatch

GatewayRoute association readme changes

Updated Validation logic for Header match filters

Reverted header match empty validation of GatewayRoute

Fixed SDK model path
Fixed few Test cases

Fixed enum for DefaultPrefix in gatewayroute CRD

Fixed Validation for Gatewayroute headers

Added Webhook Validation for VirtualRouter Path and QueryParameters
Fixed virtualrouter spec for Prefix and Path

Changed query_parameters to queryParameters in crd description for VR

Added Missing Test Cases for gatewayroute validation and conversion
Fixed enum for defaultRewrite
Fixed typo

Fixed typo
Removed unnecessary assignment of nil

removed redundant comments

Fixed some issues with GRPCRoute

Added Rewrite scenario in Conversion of GRPCGatewayroute Action

Removed TargetBased field
Changed name of field Prefix to Value
Updated Tests
Use preview models to so controller build doesn't fail
  • Loading branch information
Chinmay Gadgil committed Jun 10, 2021
1 parent c142caa commit b275285
Show file tree
Hide file tree
Showing 28 changed files with 3,561 additions and 376 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ PREVIEW=false
CRD_OPTIONS ?= "crd:trivialVersions=true,crdVersions=v1beta1"

# app mesh aws-sdk-go override in case we need to build against a custom version
APPMESH_SDK_OVERRIDE ?= "n"
APPMESH_SDK_OVERRIDE ?= "y"

ifeq ($(APPMESH_SDK_OVERRIDE), "y")
PREVIEW=true
Expand Down
127 changes: 125 additions & 2 deletions apis/appmesh/v1beta2/gatewayroute_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,44 @@ type GatewayRouteTarget struct {

// GRPCGatewayRouteMatch refers to https://docs.aws.amazon.com/app-mesh/latest/userguide/virtual_gateways.html
type GRPCGatewayRouteMatch struct {
// Either ServiceName or Hostname must be specified. Both are allowed as well
// The fully qualified domain name for the service to match from the request.
// +optional
ServiceName *string `json:"serviceName,omitempty"`
// The client specified Hostname to match on.
// +optional
Hostname *GatewayRouteHostnameMatch `json:"hostname,omitempty"`
// An object that represents the data to match from the request.
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:MaxItems=10
// +optional
Metadata []GRPCGatewayRouteMetadata `json:"metadata,omitempty"`
}

// GRPCGatewayRouteMetadata refers to https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_GrpcRouteMetadata.html
type GRPCGatewayRouteMetadata struct {
// The name of the route.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=50
Name *string `json:"name"`
// An object that represents the data to match from the request.
// +optional
Match *GRPCRouteMetadataMatchMethod `json:"match,omitempty"`
// Specify True to match anything except the match criteria. The default value is False.
// +optional
Invert *bool `json:"invert,omitempty"`
}

// GRPCGatewayRouteAction refers to https://docs.aws.amazon.com/app-mesh/latest/userguide/virtual_gateways.html
type GRPCGatewayRouteAction struct {
// An object that represents the target that traffic is routed to when a request matches the route.
Target GatewayRouteTarget `json:"target"`
// +optional
Rewrite *GrpcGatewayRouteRewrite `json:"rewrite,omitempty"`
}

type GrpcGatewayRouteRewrite struct {
Hostname *GatewayRouteHostnameRewrite `json:"hostname,omitempty"`
}

// GRPCGatewayRoute refers to https://docs.aws.amazon.com/app-mesh/latest/userguide/virtual_gateways.html
Expand All @@ -60,14 +89,103 @@ type GRPCGatewayRoute struct {

// HTTPGatewayRouteMatch refers to https://docs.aws.amazon.com/app-mesh/latest/userguide/virtual_gateways.html
type HTTPGatewayRouteMatch struct {
// Either Prefix or Hostname must be specified. Both are allowed as well.
// Specifies the path to match requests with
Prefix *string `json:"prefix"`
// +optional
Prefix *string `json:"prefix,omitempty"`
// +optional
Path *HTTPPathMatch `json:"path,omitempty"`
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:MaxItems=10
// +optional
QueryParameters []HTTPQueryParameters `json:"queryParameters,omitempty"`
// The client request method to match on.
// +kubebuilder:validation:Enum=CONNECT;DELETE;GET;HEAD;OPTIONS;PATCH;POST;PUT;TRACE
// +optional
Method *string `json:"method,omitempty"`
// The client specified Hostname to match on.
// +optional
Hostname *GatewayRouteHostnameMatch `json:"hostname,omitempty"`
// An object that represents the client request headers to match on.
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:MaxItems=10
// +optional
Headers []HTTPGatewayRouteHeader `json:"headers,omitempty"`
}

// HTTPGatewayRouteHeader refers to https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_HttpRouteHeader.html
type HTTPGatewayRouteHeader struct {
// A name for the HTTP header in the client request that will be matched on.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=50
Name string `json:"name"`
// The HeaderMatchMethod object.
// +optional
Match *HeaderMatchMethod `json:"match,omitempty"`
// Specify True to match anything except the match criteria. The default value is False.
// +optional
Invert *bool `json:"invert,omitempty"`
}

// Hostname based match, either Exact or Suffix must be specified. Both are not allowed
type GatewayRouteHostnameMatch struct {
// The value sent by the client must match the specified value exactly.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=253
// +optional
Exact *string `json:"exact,omitempty"`
// The value sent by the client must end with the specified characters.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=253
// +optional
Suffix *string `json:"suffix,omitempty"`
}

// HTTPGatewayRouteAction refers to https://docs.aws.amazon.com/app-mesh/latest/userguide/virtual_gateways.html
type HTTPGatewayRouteAction struct {
// An object that represents the target that traffic is routed to when a request matches the route.
Target GatewayRouteTarget `json:"target"`
// +optional
Rewrite *HTTPGatewayRouteRewrite `json:"rewrite,omitempty"`
}

type HTTPGatewayRouteRewrite struct {
// +optional
Prefix *GatewayRoutePrefixRewrite `json:"prefix,omitempty"`
// +optional
Path *GatewayRoutePathRewrite `json:"path,omitempty"`
//+optional
Hostname *GatewayRouteHostnameRewrite `json:"hostname,omitempty"`
}

type GatewayRoutePrefixRewrite struct {
// +optional
// +kubebuilder:validation:Enum=ENABLED;DISABLED;
DefaultPrefix *string `json:"defaultPrefix,omitempty"`
// When DefaultPrefix is specified, Value cannot be set
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=255
// +optional
Value *string `json:"value,omitempty"`
}

// Need to check this with AppMesh API team
type GatewayRouteHostnameRewrite struct {
// +optional
// +kubebuilder:validation:Enum=ENABLED;DISABLED;
DefaultTargetHostname *string `json:"defaultTargetHostname,omitempty"`
}

// Customers will be able to extend this struct in future for rewriting to a different hostname
// for now its a no-op
type GatewayRouteTargetBasedHostnameRewrite struct {
}

type GatewayRoutePathRewrite struct {
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=255
// +optional
Exact *string `json:"exact,omitempty"`
}

// HTTPGatewayRoute refers to https://docs.aws.amazon.com/app-mesh/latest/userguide/virtual_gateways.html
Expand All @@ -85,6 +203,12 @@ type GatewayRouteSpec struct {
// If unspecified or empty, it defaults to be "${name}_${namespace}" of k8s GatewayRoute
// +optional
AWSName *string `json:"awsName,omitempty"`
// Priority for the gatewayroute.
// Default Priority is 1000 which is lowest priority
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=1000
// +optional
Priority *int64 `json:"priority,omitempty"`
// An object that represents the specification of a gRPC gatewayRoute.
// +optional
GRPCRoute *GRPCGatewayRoute `json:"grpcRoute,omitempty"`
Expand Down Expand Up @@ -141,7 +265,6 @@ type GatewayRouteStatus struct {
// The current GatewayRoute status.
// +optional
Conditions []GatewayRouteCondition `json:"conditions,omitempty"`

// The generation observed by the GatewayRoute controller.
// +optional
ObservedGeneration *int64 `json:"observedGeneration,omitempty"`
Expand Down
87 changes: 87 additions & 0 deletions apis/appmesh/v1beta2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,67 @@ type Duration struct {
Value int64 `json:"value"`
}

type MatchRange struct {
// The start of the range.
Start int64 `json:"start"`
// The end of the range.
End int64 `json:"end"`
}

// HeaderMatchMethod refers to https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_HeaderMatchMethod.html
type HeaderMatchMethod struct {
// The value sent by the client must match the specified value exactly.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=255
// +optional
Exact *string `json:"exact,omitempty"`
// The value sent by the client must begin with the specified characters.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=255
// +optional
Prefix *string `json:"prefix,omitempty"`
// An object that represents the range of values to match on.
// +optional
Range *MatchRange `json:"range,omitempty"`
// The value sent by the client must include the specified characters.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=255
// +optional
Regex *string `json:"regex,omitempty"`
// The value sent by the client must end with the specified characters.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=255
// +optional
Suffix *string `json:"suffix,omitempty"`
}

// GRPCRouteMetadataMatchMethod refers to https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_GrpcRouteMetadataMatchMethod.html
type GRPCRouteMetadataMatchMethod struct {
// The value sent by the client must match the specified value exactly.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=255
// +optional
Exact *string `json:"exact,omitempty"`
// The value sent by the client must begin with the specified characters.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=255
// +optional
Prefix *string `json:"prefix,omitempty"`
// An object that represents the range of values to match on
// +optional
Range *MatchRange `json:"range,omitempty"`
// The value sent by the client must include the specified characters.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=255
// +optional
Regex *string `json:"regex,omitempty"`
// The value sent by the client must end with the specified characters.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=255
// +optional
Suffix *string `json:"suffix,omitempty"`
}

// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Maximum=65535
type PortNumber int64
Expand Down Expand Up @@ -90,6 +151,32 @@ type VirtualGatewayReference struct {
UID types.UID `json:"uid"`
}

type HTTPPathMatch struct {
// The value sent by the client must match the specified value exactly.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=255
// +optional
Exact *string `json:"exact,omitempty"`
// The value sent by the client must end with the specified characters.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=255
// +optional
Regex *string `json:"regex,omitempty"`
}
type HTTPQueryParameters struct {
Name *string `json:"name"`
// The HeaderMatchMethod object.
// +optional
Match *QueryMatchMethod `json:"match,omitempty"`
}

type QueryMatchMethod struct {
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=255
// +optional
Exact *string `json:"exact,omitempty"`
}

type HTTPTimeout struct {
// An object that represents per request timeout duration.
// +optional
Expand Down
76 changes: 11 additions & 65 deletions apis/appmesh/v1beta2/virtualrouter_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,42 +41,6 @@ type WeightedTarget struct {
Weight int64 `json:"weight"`
}

type MatchRange struct {
// The start of the range.
// +optional
Start int64 `json:"start"`
// The end of the range.
// +optional
End int64 `json:"end"`
}

// HeaderMatchMethod refers to https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_HeaderMatchMethod.html
type HeaderMatchMethod struct {
// The value sent by the client must match the specified value exactly.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=255
// +optional
Exact *string `json:"exact,omitempty"`
// The value sent by the client must begin with the specified characters.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=255
// +optional
Prefix *string `json:"prefix,omitempty"`
// An object that represents the range of values to match on.
// +optional
Range *MatchRange `json:"range,omitempty"`
// The value sent by the client must include the specified characters.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=255
// +optional
Regex *string `json:"regex,omitempty"`
// The value sent by the client must end with the specified characters.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=255
// +optional
Suffix *string `json:"suffix,omitempty"`
}

// HTTPRouteHeader refers to https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_HttpRouteHeader.html
type HTTPRouteHeader struct {
// A name for the HTTP header in the client request that will be matched on.
Expand All @@ -102,12 +66,21 @@ type HTTPRouteMatch struct {
// +kubebuilder:validation:Enum=CONNECT;DELETE;GET;HEAD;OPTIONS;PATCH;POST;PUT;TRACE
// +optional
Method *string `json:"method,omitempty"`
// Specifies the path to match requests with
Prefix string `json:"prefix"`
// Specifies the prefix to match requests with
// +optional
Prefix *string `json:"prefix,omitempty"`
// The client request scheme to match on
// +kubebuilder:validation:Enum=http;https
// +optional
Scheme *string `json:"scheme,omitempty"`
// The client specified Path to match on.
// +optional
Path *HTTPPathMatch `json:"path,omitempty"`
// The client specified queryParameters to match on
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:MaxItems=10
// +optional
QueryParameters []HTTPQueryParameters `json:"queryParameters,omitempty"`
}

// HTTPRouteAction refers to https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_HttpRouteAction.html
Expand Down Expand Up @@ -175,33 +148,6 @@ type TCPRoute struct {
Timeout *TCPTimeout `json:"timeout,omitempty"`
}

// GRPCRouteMetadataMatchMethod refers to https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_GrpcRouteMetadataMatchMethod.html
type GRPCRouteMetadataMatchMethod struct {
// The value sent by the client must match the specified value exactly.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=255
// +optional
Exact *string `json:"exact,omitempty"`
// The value sent by the client must begin with the specified characters.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=255
// +optional
Prefix *string `json:"prefix,omitempty"`
// An object that represents the range of values to match on
// +optional
Range *MatchRange `json:"range,omitempty"`
// The value sent by the client must include the specified characters.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=255
// +optional
Regex *string `json:"regex,omitempty"`
// The value sent by the client must end with the specified characters.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=255
// +optional
Suffix *string `json:"suffix,omitempty"`
}

// GRPCRouteMetadata refers to https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_GrpcRouteMetadata.html
type GRPCRouteMetadata struct {
// The name of the route.
Expand Down
Loading

0 comments on commit b275285

Please sign in to comment.