Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
3f1f3f0
feat: add Body scope to ApisixRoute match expressions for request bod…
AlinsRan May 9, 2026
a653ef9
feat: add CEL validation and e2e tests for Body scope matching
AlinsRan May 9, 2026
24f7e0c
chore: remove CEL XValidation, keep Enum marker for Scope field
AlinsRan May 9, 2026
930df17
fix: address PR review comments
AlinsRan May 9, 2026
64ffc78
feat: add CEL XValidation for ApisixRouteHTTPMatchExprSubject
AlinsRan May 9, 2026
800c57c
fix: use size(self.name) > 0 in CEL rule to avoid YAML quote issues
AlinsRan May 9, 2026
a32cacf
Apply suggestions from code review
AlinsRan May 11, 2026
92325fd
Potential fix for pull request finding
AlinsRan May 11, 2026
271976c
feat: support Body scope in ApisixRoute HTTP match expressions
AlinsRan May 11, 2026
dd377dd
chore: merge master and fix consumer test after algorithm CEL rule ad…
AlinsRan May 11, 2026
ce311b2
refactor: rename validateObject to Validate, restore missing consumer…
AlinsRan May 11, 2026
a171b69
feat(api): add HealthCheck types to BackendTrafficPolicySpec
AlinsRan May 11, 2026
f839117
chore: regenerate deepcopy for BackendTrafficPolicy health check types
AlinsRan May 11, 2026
0c19a9d
feat: translate BackendTrafficPolicy health checks to APISIX upstream
AlinsRan May 11, 2026
a03d90d
chore: regenerate CRD manifests with BackendTrafficPolicy health chec…
AlinsRan May 11, 2026
9eecf12
fix: use trim() in CEL rule to reject whitespace-only name for non-Pa…
AlinsRan May 12, 2026
3cbb4ca
fix: replace trim() CEL rule with Pattern annotation to avoid cost bu…
AlinsRan May 12, 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
140 changes: 140 additions & 0 deletions api/v1alpha1/backendtrafficpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ type BackendTrafficPolicySpec struct {
// UpstreamHost specifies the host of the Upstream request. Used only if
// passHost is set to `rewrite`.
Host Hostname `json:"upstreamHost,omitempty" yaml:"upstreamHost,omitempty"`

// HealthCheck defines active and passive health check configuration for
// the upstream backends. When configured, APISIX will probe backends
// (active) or monitor live traffic (passive) to detect and bypass
// unhealthy nodes.
// +optional
HealthCheck *HealthCheck `json:"healthCheck,omitempty" yaml:"healthCheck,omitempty"`
}

// LoadBalancer describes the load balancing parameters.
Expand Down Expand Up @@ -125,6 +132,139 @@ type BackendTrafficPolicyList struct {
Items []BackendTrafficPolicy `json:"items"`
}

// HealthCheck defines the active and passive health check configuration for upstream nodes.
type HealthCheck struct {
// Active health checks proactively send requests to upstream nodes to determine their availability.
// +kubebuilder:validation:Required
Active *ActiveHealthCheck `json:"active" yaml:"active"`
// Passive health checks evaluate upstream health based on observed traffic (timeouts, errors).
// +kubebuilder:validation:Optional
Passive *PassiveHealthCheck `json:"passive,omitempty" yaml:"passive,omitempty"`
}

// ActiveHealthCheck defines the active upstream health check configuration.
type ActiveHealthCheck struct {
// Type is the health check type. Can be `http`, `https`, or `tcp`.
// +kubebuilder:validation:Enum=http;https;tcp;
// +kubebuilder:default=http
// +optional
Type string `json:"type,omitempty" yaml:"type,omitempty"`

// Timeout sets health check timeout.
// +optional
Timeout metav1.Duration `json:"timeout,omitempty" yaml:"timeout,omitempty"`

// Concurrency sets the number of targets to be checked at the same time.
// +kubebuilder:validation:Minimum=0
// +optional
Concurrency int `json:"concurrency,omitempty" yaml:"concurrency,omitempty"`

// Host sets the upstream host used in the health check request.
// +optional
Host string `json:"host,omitempty" yaml:"host,omitempty"`

// Port sets the port on the upstream node to probe.
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Maximum=65535
// +optional
Port int32 `json:"port,omitempty" yaml:"port,omitempty"`

// HTTPPath sets the HTTP path for the probe request.
// +optional
HTTPPath string `json:"httpPath,omitempty" yaml:"httpPath,omitempty"`

// StrictTLS controls whether TLS certificate validation is enforced.
// +optional
StrictTLS *bool `json:"strictTLS,omitempty" yaml:"strictTLS,omitempty"`

// RequestHeaders sets additional HTTP request headers for the probe.
// +optional
RequestHeaders []string `json:"requestHeaders,omitempty" yaml:"requestHeaders,omitempty"`

// Healthy configures the thresholds for marking a node healthy.
// +optional
Healthy *ActiveHealthCheckHealthy `json:"healthy,omitempty" yaml:"healthy,omitempty"`

// Unhealthy configures the thresholds for marking a node unhealthy.
// +optional
Unhealthy *ActiveHealthCheckUnhealthy `json:"unhealthy,omitempty" yaml:"unhealthy,omitempty"`
}

// PassiveHealthCheck defines passive health check configuration based on observed traffic.
type PassiveHealthCheck struct {
// Type is the passive health check type. Can be `http`, `https`, or `tcp`.
// +kubebuilder:validation:Enum=http;https;tcp;
// +kubebuilder:default=http
// +optional
Type string `json:"type,omitempty" yaml:"type,omitempty"`

// Healthy defines conditions under which a node is considered healthy.
// +optional
Healthy *PassiveHealthCheckHealthy `json:"healthy,omitempty" yaml:"healthy,omitempty"`

// Unhealthy defines conditions under which a node is considered unhealthy.
// +optional
Unhealthy *PassiveHealthCheckUnhealthy `json:"unhealthy,omitempty" yaml:"unhealthy,omitempty"`
}

// ActiveHealthCheckHealthy defines thresholds for actively marking an upstream node healthy.
type ActiveHealthCheckHealthy struct {
PassiveHealthCheckHealthy `json:",inline" yaml:",inline"`

// Interval defines the time between health check probes.
// Minimum is 1s.
Interval metav1.Duration `json:"interval,omitempty" yaml:"interval,omitempty"`
}

// ActiveHealthCheckUnhealthy defines thresholds for actively marking an upstream node unhealthy.
type ActiveHealthCheckUnhealthy struct {
PassiveHealthCheckUnhealthy `json:",inline" yaml:",inline"`

// Interval defines the time between health check probes.
// Minimum is 1s.
Interval metav1.Duration `json:"interval,omitempty" yaml:"interval,omitempty"`
}

// PassiveHealthCheckHealthy defines conditions for passively marking a node healthy.
type PassiveHealthCheckHealthy struct {
// HTTPCodes is the list of HTTP status codes considered healthy.
// +kubebuilder:validation:MinItems=1
// +optional
HTTPCodes []int `json:"httpCodes,omitempty" yaml:"httpCodes,omitempty"`

// Successes is the number of consecutive successful responses required to mark a node healthy.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=254
// +optional
Successes int `json:"successes,omitempty" yaml:"successes,omitempty"`
}

// PassiveHealthCheckUnhealthy defines conditions for passively marking a node unhealthy.
type PassiveHealthCheckUnhealthy struct {
// HTTPCodes is the list of HTTP status codes considered unhealthy.
// +kubebuilder:validation:MinItems=1
// +optional
HTTPCodes []int `json:"httpCodes,omitempty" yaml:"httpCodes,omitempty"`

// HTTPFailures is the number of HTTP failures to mark a node unhealthy.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=254
// +optional
HTTPFailures int `json:"httpFailures,omitempty" yaml:"httpFailures,omitempty"`

// TCPFailures is the number of TCP failures to mark a node unhealthy.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=254
// +optional
TCPFailures int `json:"tcpFailures,omitempty" yaml:"tcpFailures,omitempty"`

// Timeouts is the number of timeouts to mark a node unhealthy.
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Maximum=254
// +optional
Timeouts int `json:"timeout,omitempty" yaml:"timeout,omitempty"`
}

func init() {
SchemeBuilder.Register(&BackendTrafficPolicy{}, &BackendTrafficPolicyList{})
}
165 changes: 165 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