Skip to content

Commit

Permalink
API: Support FaultInjection in BackendTrafficPolicy
Browse files Browse the repository at this point in the history
Signed-off-by: zhaonan <[email protected]>
  • Loading branch information
zhaonan committed Dec 15, 2023
1 parent 9aebfdc commit c197ba1
Show file tree
Hide file tree
Showing 5 changed files with 216 additions and 0 deletions.
4 changes: 4 additions & 0 deletions api/v1alpha1/backendtrafficpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ type BackendTrafficPolicySpec struct {
//
// +optional
TCPKeepalive *TCPKeepalive `json:"tcpKeepalive,omitempty"`

// FaultInjection defines the fault injection policy to be applied. Support delays and aborts.
// +optional
FaultInjection *FaultInjection `json:"faultInjection,omitempty"`
}

// BackendTrafficPolicyStatus defines the state of BackendTrafficPolicy
Expand Down
48 changes: 48 additions & 0 deletions api/v1alpha1/fault_injection.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright Envoy Gateway Authors
// SPDX-License-Identifier: Apache-2.0
// The full text of the Apache license is available in the LICENSE file at
// the root of the repo.

package v1alpha1

import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

// FaultInjection defines the fault injection policy to be applied. Support delays and aborts.
type FaultInjection struct {

// If specified, the delay will inject a fixed delay into the request
//
// +optional
Delay *DelayConfig `json:"delay,omitempty"`

// If specified, the abort will abort the request with the specified HTTP status code
//
// +optional
Abort *AbortConfig `json:"abort,omitempty"`
}

// DelayConfig defines the delay fault injection configuration
type DelayConfig struct {
// FixedDelay specifies the fixed delay duration
//
// +required
FixedDelay *metav1.Duration `json:"fixedDelay"`

// Percentage specifies the percentage of requests to be delayed. Default 100%, if set 0, no requests will be delayed.
// +optional
// +kubebuilder:default=100
Percentage *int `json:"percentage"`
}

// AbortConfig defines the abort fault injection configuration
type AbortConfig struct {
// StatusCode specifies the HTTP/GRPC status code to be returned
//
// +required
StatusCode *int `json:"statusCode"`

// Percentage specifies the percentage of requests to be aborted. Default 100%, if set 0, no requests will be aborted.
// +optional
// +kubebuilder:default=100
Percentage *int `json:"percentage"`
}
80 changes: 80 additions & 0 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 @@ -44,6 +44,44 @@ spec:
spec:
description: spec defines the desired state of BackendTrafficPolicy.
properties:
faultInjection:
description: FaultInjection defines the fault injection policy to
be applied. Support delays and aborts.
properties:
abort:
description: If specified, the abort will abort the request with
the specified HTTP status code
properties:
percentage:
default: 100
description: Percentage specifies the percentage of requests
to be aborted. Default 100%, if set 0, no requests will
be aborted.
type: integer
statusCode:
description: StatusCode specifies the HTTP/GRPC status code
to be returned
type: integer
required:
- statusCode
type: object
delay:
description: If specified, the delay will inject a fixed delay
into the request
properties:
fixedDelay:
description: FixedDelay specifies the fixed delay duration
type: string
percentage:
default: 100
description: Percentage specifies the percentage of requests
to be delayed. Default 100%, if set 0, no requests will
be delayed.
type: integer
required:
- fixedDelay
type: object
type: object
loadBalancer:
description: LoadBalancer policy to apply when routing traffic from
the gateway to the backend endpoints
Expand Down
46 changes: 46 additions & 0 deletions site/content/en/latest/api/extension_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ API group.



#### AbortConfig



AbortConfig defines the abort fault injection configuration

_Appears in:_
- [FaultInjection](#faultinjection)

| Field | Description |
| --- | --- |
| `statusCode` _integer_ | StatusCode specifies the HTTP/GRPC status code to be returned |
| `percentage` _integer_ | Percentage specifies the percentage of requests to be aborted. Default 100%, if set 0, no requests will be aborted. |


#### BackendTrafficPolicy


Expand Down Expand Up @@ -76,6 +91,7 @@ _Appears in:_
| `loadBalancer` _[LoadBalancer](#loadbalancer)_ | LoadBalancer policy to apply when routing traffic from the gateway to the backend endpoints |
| `proxyProtocol` _[ProxyProtocol](#proxyprotocol)_ | ProxyProtocol enables the Proxy Protocol when communicating with the backend. |
| `tcpKeepalive` _[TCPKeepalive](#tcpkeepalive)_ | TcpKeepalive settings associated with the upstream client connection. Disabled by default. |
| `faultInjection` _[FaultInjection](#faultinjection)_ | FaultInjection defines the fault injection policy to be applied. Support delays and aborts. |



Expand Down Expand Up @@ -244,6 +260,21 @@ _Appears in:_



#### DelayConfig



DelayConfig defines the delay fault injection configuration

_Appears in:_
- [FaultInjection](#faultinjection)

| Field | Description |
| --- | --- |
| `fixedDelay` _[Duration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.26/#duration-v1-meta)_ | FixedDelay specifies the fixed delay duration |
| `percentage` _integer_ | Percentage specifies the percentage of requests to be delayed. Default 100%, if set 0, no requests will be delayed. |


#### EnvironmentCustomTag


Expand Down Expand Up @@ -774,6 +805,21 @@ _Appears in:_
CertificateRef can only reference a Kubernetes Secret at this time. |


#### FaultInjection



FaultInjection defines the fault injection policy to be applied. Support delays and aborts.

_Appears in:_
- [BackendTrafficPolicySpec](#backendtrafficpolicyspec)

| Field | Description |
| --- | --- |
| `delay` _[DelayConfig](#delayconfig)_ | If specified, the delay will inject a fixed delay into the request |
| `abort` _[AbortConfig](#abortconfig)_ | If specified, the abort will abort the request with the specified HTTP status code |


#### FileEnvoyProxyAccessLog


Expand Down

0 comments on commit c197ba1

Please sign in to comment.