Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(MeshHTTPRoute): add RequestMirror filter #6064

Merged
merged 8 commits into from
Feb 20, 2023
19 changes: 19 additions & 0 deletions api/common/v1alpha1/targetref.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
// +kubebuilder:object:generate=true
package v1alpha1

import (
"fmt"
"sort"
"strings"

"golang.org/x/exp/maps"
)

type TargetRefKind string

var (
Expand Down Expand Up @@ -37,3 +45,14 @@ type TargetRef struct {
// Mesh is reserved for future use to identify cross mesh resources.
Mesh string `json:"mesh,omitempty"`
}

// Hash returns a hash of the TargetRef
func (in *TargetRef) Hash() string {
keys := maps.Keys(in.Tags)
sort.Strings(keys)
orderedTags := make([]string, len(keys))
for _, k := range keys {
orderedTags = append(orderedTags, fmt.Sprintf("%s=%s", k, in.Tags[k]))
}
return fmt.Sprintf("%s/%s/%s/%s", in.Kind, in.Name, strings.Join(orderedTags, "/"), in.Mesh)
}
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,52 @@ spec:
- name
x-kubernetes-list-type: map
type: object
requestMirror:
properties:
backendRef:
description: TargetRef defines structure
that allows attaching policy to various
objects
properties:
kind:
description: Kind of the referenced
resource
enum:
- Mesh
- MeshSubset
- MeshService
- MeshServiceSubset
- MeshGatewayRoute
type: string
mesh:
description: Mesh is reserved for future
use to identify cross mesh resources.
type: string
name:
description: 'Name of the referenced
resource. Can only be used with kinds:
`MeshService`, `MeshServiceSubset`
and `MeshGatewayRoute`'
type: string
tags:
additionalProperties:
type: string
description: Tags used to select a subset
of proxies by tags. Can only be used
with kinds `MeshSubset` and `MeshServiceSubset`
type: object
type: object
percentage:
anyOf:
- type: integer
- type: string
description: Percentage of requests to mirror.
If not specified, all requests to the
target cluster will be mirrored.
x-kubernetes-int-or-string: true
required:
- backendRef
type: object
requestRedirect:
properties:
hostname:
Expand Down Expand Up @@ -1335,6 +1381,7 @@ spec:
- ResponseHeaderModifier
- RequestRedirect
- URLRewrite
- RequestMirror
type: string
urlRewrite:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,52 @@ spec:
- name
x-kubernetes-list-type: map
type: object
requestMirror:
properties:
backendRef:
description: TargetRef defines structure
that allows attaching policy to various
objects
properties:
kind:
description: Kind of the referenced
resource
enum:
- Mesh
- MeshSubset
- MeshService
- MeshServiceSubset
- MeshGatewayRoute
type: string
mesh:
description: Mesh is reserved for future
use to identify cross mesh resources.
type: string
name:
description: 'Name of the referenced
resource. Can only be used with kinds:
`MeshService`, `MeshServiceSubset`
and `MeshGatewayRoute`'
type: string
tags:
additionalProperties:
type: string
description: Tags used to select a subset
of proxies by tags. Can only be used
with kinds `MeshSubset` and `MeshServiceSubset`
type: object
type: object
percentage:
anyOf:
- type: integer
- type: string
description: Percentage of requests to mirror.
If not specified, all requests to the
target cluster will be mirrored.
x-kubernetes-int-or-string: true
required:
- backendRef
type: object
requestRedirect:
properties:
hostname:
Expand Down Expand Up @@ -1335,6 +1381,7 @@ spec:
- ResponseHeaderModifier
- RequestRedirect
- URLRewrite
- RequestMirror
type: string
urlRewrite:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,52 @@ spec:
- name
x-kubernetes-list-type: map
type: object
requestMirror:
properties:
backendRef:
description: TargetRef defines structure
that allows attaching policy to various
objects
properties:
kind:
description: Kind of the referenced
resource
enum:
- Mesh
- MeshSubset
- MeshService
- MeshServiceSubset
- MeshGatewayRoute
type: string
mesh:
description: Mesh is reserved for future
use to identify cross mesh resources.
type: string
name:
description: 'Name of the referenced
resource. Can only be used with kinds:
`MeshService`, `MeshServiceSubset`
and `MeshGatewayRoute`'
type: string
tags:
additionalProperties:
type: string
description: Tags used to select a subset
of proxies by tags. Can only be used
with kinds `MeshSubset` and `MeshServiceSubset`
type: object
type: object
percentage:
anyOf:
- type: integer
- type: string
description: Percentage of requests to mirror.
If not specified, all requests to the
target cluster will be mirrored.
x-kubernetes-int-or-string: true
required:
- backendRef
type: object
requestRedirect:
properties:
hostname:
Expand Down Expand Up @@ -1487,6 +1533,7 @@ spec:
- ResponseHeaderModifier
- RequestRedirect
- URLRewrite
- RequestMirror
type: string
urlRewrite:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1236,6 +1236,52 @@ spec:
- name
x-kubernetes-list-type: map
type: object
requestMirror:
properties:
backendRef:
description: TargetRef defines structure
that allows attaching policy to various
objects
properties:
kind:
description: Kind of the referenced
resource
enum:
- Mesh
- MeshSubset
- MeshService
- MeshServiceSubset
- MeshGatewayRoute
type: string
mesh:
description: Mesh is reserved for future
use to identify cross mesh resources.
type: string
name:
description: 'Name of the referenced
resource. Can only be used with kinds:
`MeshService`, `MeshServiceSubset`
and `MeshGatewayRoute`'
type: string
tags:
additionalProperties:
type: string
description: Tags used to select a subset
of proxies by tags. Can only be used
with kinds `MeshSubset` and `MeshServiceSubset`
type: object
type: object
percentage:
anyOf:
- type: integer
- type: string
description: Percentage of requests to mirror.
If not specified, all requests to the
target cluster will be mirrored.
x-kubernetes-int-or-string: true
required:
- backendRef
type: object
requestRedirect:
properties:
hostname:
Expand Down Expand Up @@ -1355,6 +1401,7 @@ spec:
- ResponseHeaderModifier
- RequestRedirect
- URLRewrite
- RequestMirror
type: string
urlRewrite:
properties:
Expand Down
47 changes: 47 additions & 0 deletions app/kumactl/cmd/install/testdata/install-crds.all.golden.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2433,6 +2433,52 @@ spec:
- name
x-kubernetes-list-type: map
type: object
requestMirror:
properties:
backendRef:
description: TargetRef defines structure
that allows attaching policy to various
objects
properties:
kind:
description: Kind of the referenced
resource
enum:
- Mesh
- MeshSubset
- MeshService
- MeshServiceSubset
- MeshGatewayRoute
type: string
mesh:
description: Mesh is reserved for future
use to identify cross mesh resources.
type: string
name:
description: 'Name of the referenced
resource. Can only be used with kinds:
`MeshService`, `MeshServiceSubset`
and `MeshGatewayRoute`'
type: string
tags:
additionalProperties:
type: string
description: Tags used to select a subset
of proxies by tags. Can only be used
with kinds `MeshSubset` and `MeshServiceSubset`
type: object
type: object
percentage:
anyOf:
- type: integer
- type: string
description: Percentage of requests to mirror.
If not specified, all requests to the
target cluster will be mirrored.
x-kubernetes-int-or-string: true
required:
- backendRef
type: object
requestRedirect:
properties:
hostname:
Expand Down Expand Up @@ -2552,6 +2598,7 @@ spec:
- ResponseHeaderModifier
- RequestRedirect
- URLRewrite
- RequestMirror
type: string
urlRewrite:
properties:
Expand Down
Loading