Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ae64948
add admission control functionality
aburan28 Nov 15, 2025
fead370
add admission control functionality crds
aburan28 Nov 15, 2025
ed7451d
fix the lint errors
aburan28 Nov 30, 2025
31febb0
fix: address CI lint and gen-check failures for admission control
aburan28 Feb 13, 2026
0fca7f5
incorporate some feedback
aburan28 Feb 23, 2026
ce38d07
update helm template test outputs after merge with upstream/main
aburan28 Feb 28, 2026
eef4e1a
use envoy defaults
aburan28 Mar 2, 2026
24f177b
use envoy defaults
aburan28 Mar 2, 2026
37b648f
add out files
aburan28 Mar 6, 2026
a75dfac
add testdata gen
aburan28 Mar 8, 2026
4988451
regenerate crds
aburan28 Mar 8, 2026
3f7d253
setup admission control as http upstream filter
aburan28 Mar 15, 2026
3696a2c
change to aggression
aburan28 Mar 22, 2026
566c3a9
change to aggression
aburan28 Mar 22, 2026
a16039d
fix: resolve rebase conflicts and regenerate testdata
aburan28 Mar 30, 2026
807a476
fix: address review feedback for admission control
aburan28 Apr 10, 2026
6545ecc
Merge branch 'main' into adam--add-admission-control
aburan28 Apr 11, 2026
97fc2da
test: regenerate admission-control testdata
aburan28 Apr 11, 2026
ead9d6d
test: regenerate helm-template snapshots and extension docs
aburan28 Apr 11, 2026
2a8a41a
Merge remote-tracking branch 'upstream/main' into adam--add-admission…
aburan28 Apr 17, 2026
a65fc3d
fix(admission-control): use new() instead of ptr.To to satisfy forbid…
aburan28 Apr 17, 2026
a98b9e2
address review feedback: revert HCM filter ordering, hoist gRPC code …
aburan28 Apr 17, 2026
7b7bfdb
Remove namespace from admission control targetRef
aburan28 Apr 18, 2026
16fc1f4
Address admission control review feedback
aburan28 Apr 24, 2026
80c8975
Merge branch 'main' into adam--add-admission-control
jukie Apr 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions api/v1alpha1/admission_control.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
// 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 (
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
)

// AdmissionControl defines the admission control policy to be applied.
// This configuration probabilistically rejects requests based on the success rate
// of previous requests in a configurable sliding time window.
// All fields are optional and will use Envoy's defaults when not specified.
//
// +kubebuilder:validation:XValidation:rule="!has(self.successRateThreshold) || (self.successRateThreshold >= 1 && self.successRateThreshold <= 100)",message="successRateThreshold must be between 1 and 100"
// +kubebuilder:validation:XValidation:rule="!has(self.maxRejectionProbability) || (self.maxRejectionProbability >= 0 && self.maxRejectionProbability <= 100)",message="maxRejectionProbability must be between 0 and 100"
type AdmissionControl struct {
Comment thread
aburan28 marked this conversation as resolved.
// SamplingWindow defines the time window over which request success rates are calculated.
// Defaults to 30s if not specified.
//
// +optional
SamplingWindow *gwapiv1.Duration `json:"samplingWindow,omitempty"`

// SuccessRateThreshold is the lowest request success rate, as a percentage in the
// range [1, 100], at which the filter will not reject requests. Defaults to 95 if
// not specified. Envoy rejects values below 1%, so values lower than 1 are not allowed.
//
// +optional
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Maximum=100
SuccessRateThreshold *uint32 `json:"successRateThreshold,omitempty"`

// Aggression controls the rejection probability curve. A value of 1 means a linear
// increase in rejection probability as the success rate decreases. Higher values
// result in more aggressive rejection at higher success rates.
// Envoy requires aggression to be greater than 0 and clamps values below 1 to 1.
// Defaults to 1 if not specified.
//
// +optional
// +kubebuilder:validation:Minimum=1
Aggression *uint32 `json:"aggression,omitempty"`

// RPSThreshold defines the minimum requests per second below which requests will
// pass through the filter without rejection. Defaults to 0 if not specified.
//
// +optional
// +kubebuilder:validation:Minimum=0
RPSThreshold *uint32 `json:"rpsThreshold,omitempty"`

// MaxRejectionProbability represents the upper limit of the rejection probability,
// expressed as a percentage in the range [0, 100]. Defaults to 80 if not specified.
//
// +optional
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=100
MaxRejectionProbability *uint32 `json:"maxRejectionProbability,omitempty"`

// SuccessCriteria defines what constitutes a successful request for both HTTP and gRPC.
//
// +optional
SuccessCriteria *AdmissionControlSuccessCriteria `json:"successCriteria,omitempty"`
}

// AdmissionControlSuccessCriteria defines the criteria for determining successful requests.
type AdmissionControlSuccessCriteria struct {
// HTTP defines success criteria for HTTP requests.
//
// +optional
HTTP *HTTPSuccessCriteria `json:"http,omitempty"`

// GRPC defines success criteria for gRPC requests.
//
// +optional
GRPC *GRPCSuccessCriteria `json:"grpc,omitempty"`
}

// HTTPSuccessCriteria defines success criteria for HTTP requests.
type HTTPSuccessCriteria struct {
// HTTPSuccessStatus defines HTTP status codes that are considered successful.
//
// +optional
HTTPSuccessStatus []HTTPStatus `json:"httpSuccessStatus,omitempty"`
}

// GRPCSuccessCode defines gRPC status codes as defined in
// https://github.com/grpc/grpc/blob/master/doc/statuscodes.md#status-codes-and-their-use-in-grpc.
// +kubebuilder:validation:Enum=Ok;Cancelled;Unknown;InvalidArgument;DeadlineExceeded;NotFound;AlreadyExists;PermissionDenied;ResourceExhausted;FailedPrecondition;Aborted;OutOfRange;Unimplemented;Internal;Unavailable;DataLoss;Unauthenticated
type GRPCSuccessCode string

const (
GRPCSuccessCodeOk GRPCSuccessCode = "Ok"
GRPCSuccessCodeCancelled GRPCSuccessCode = "Cancelled"
GRPCSuccessCodeUnknown GRPCSuccessCode = "Unknown"
GRPCSuccessCodeInvalidArgument GRPCSuccessCode = "InvalidArgument"
GRPCSuccessCodeDeadlineExceeded GRPCSuccessCode = "DeadlineExceeded"
GRPCSuccessCodeNotFound GRPCSuccessCode = "NotFound"
GRPCSuccessCodeAlreadyExists GRPCSuccessCode = "AlreadyExists"
GRPCSuccessCodePermissionDenied GRPCSuccessCode = "PermissionDenied"
GRPCSuccessCodeResourceExhausted GRPCSuccessCode = "ResourceExhausted"
GRPCSuccessCodeFailedPrecondition GRPCSuccessCode = "FailedPrecondition"
GRPCSuccessCodeAborted GRPCSuccessCode = "Aborted"
GRPCSuccessCodeOutOfRange GRPCSuccessCode = "OutOfRange"
GRPCSuccessCodeUnimplemented GRPCSuccessCode = "Unimplemented"
GRPCSuccessCodeInternal GRPCSuccessCode = "Internal"
GRPCSuccessCodeUnavailable GRPCSuccessCode = "Unavailable"
GRPCSuccessCodeDataLoss GRPCSuccessCode = "DataLoss"
GRPCSuccessCodeUnauthenticated GRPCSuccessCode = "Unauthenticated"
)

// GRPCSuccessCriteria defines success criteria for gRPC requests.
type GRPCSuccessCriteria struct {
Comment thread
aburan28 marked this conversation as resolved.
// GRPCSuccessStatus defines gRPC status codes that are considered successful.
// Status codes are defined in https://github.com/grpc/grpc/blob/master/doc/statuscodes.md#status-codes-and-their-use-in-grpc.
//
// +optional
GRPCSuccessStatus []GRPCSuccessCode `json:"grpcSuccessStatus,omitempty"`
}
6 changes: 6 additions & 0 deletions api/v1alpha1/backendtrafficpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ type BackendTrafficPolicySpec struct {
// +optional
FaultInjection *FaultInjection `json:"faultInjection,omitempty"`

// AdmissionControl defines the admission control policy to be applied. This configuration
// probabilistically rejects requests based on the success rate of previous requests in a
// configurable sliding time window.
// +optional
AdmissionControl *AdmissionControl `json:"admissionControl,omitempty"`
Comment thread
jukie marked this conversation as resolved.

// UseClientProtocol configures Envoy to prefer sending requests to backends using
// the same HTTP protocol that the incoming request used. Defaults to false, which means
// that Envoy will use the protocol indicated by the attached BackendRef.
Expand Down
5 changes: 4 additions & 1 deletion api/v1alpha1/envoyproxy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ type FilterPosition struct {
}

// EnvoyFilter defines the type of Envoy HTTP filter.
// +kubebuilder:validation:Enum=envoy.filters.http.custom_response;envoy.filters.http.health_check;envoy.filters.http.fault;envoy.filters.http.cors;envoy.filters.http.header_mutation;envoy.filters.http.ext_authz;envoy.filters.http.api_key_auth;envoy.filters.http.basic_auth;envoy.filters.http.oauth2;envoy.filters.http.jwt_authn;envoy.filters.http.stateful_session;envoy.filters.http.buffer;envoy.filters.http.lua;envoy.filters.http.ext_proc;envoy.filters.http.wasm;envoy.filters.http.dynamic_modules;envoy.filters.http.geoip;envoy.filters.http.rbac;envoy.filters.http.local_ratelimit;envoy.filters.http.ratelimit;envoy.filters.http.grpc_web;envoy.filters.http.grpc_stats;envoy.filters.http.credential_injector;envoy.filters.http.compressor;envoy.filters.http.dynamic_forward_proxy
// +kubebuilder:validation:Enum=envoy.filters.http.custom_response;envoy.filters.http.health_check;envoy.filters.http.fault;envoy.filters.http.admission_control;envoy.filters.http.cors;envoy.filters.http.header_mutation;envoy.filters.http.ext_authz;envoy.filters.http.api_key_auth;envoy.filters.http.basic_auth;envoy.filters.http.oauth2;envoy.filters.http.jwt_authn;envoy.filters.http.stateful_session;envoy.filters.http.buffer;envoy.filters.http.lua;envoy.filters.http.ext_proc;envoy.filters.http.wasm;envoy.filters.http.dynamic_modules;envoy.filters.http.geoip;envoy.filters.http.rbac;envoy.filters.http.local_ratelimit;envoy.filters.http.ratelimit;envoy.filters.http.grpc_web;envoy.filters.http.grpc_stats;envoy.filters.http.credential_injector;envoy.filters.http.compressor;envoy.filters.http.dynamic_forward_proxy
type EnvoyFilter string

const (
Expand All @@ -299,6 +299,9 @@ const (
// EnvoyFilterFault defines the Envoy HTTP fault filter.
EnvoyFilterFault EnvoyFilter = "envoy.filters.http.fault"

// EnvoyFilterAdmissionControl defines the Envoy HTTP admission control filter.
EnvoyFilterAdmissionControl EnvoyFilter = "envoy.filters.http.admission_control"

// EnvoyFilterCORS defines the Envoy HTTP CORS filter.
EnvoyFilterCORS EnvoyFilter = "envoy.filters.http.cors"

Expand Down
115 changes: 115 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.

Loading
Loading