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: Apache APISIX SetHeader support. Fixes #2668 #2678

Merged
merged 5 commits into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ For these reasons, in large scale high-volume production environments, a rolling
|-----------------------------------|------------------------------|-----------------------------|----------------------------|----------------------------|
| ALB Ingress Controller | :white_check_mark: (stable) | :white_check_mark: (stable) | :x: | :white_check_mark: (alpha) |
| Ambassador | :white_check_mark: (stable) | :x: | :x: | :x: |
| Apache APISIX Ingress Controller | :white_check_mark: (alpha) | :x: | :x: | :x: |
| Apache APISIX Ingress Controller | :white_check_mark: (alpha) | :x: | :x: | :white_check_mark: (alpha) |
| Istio | :white_check_mark: (stable) | :white_check_mark: (stable) | :white_check_mark: (alpha) | :white_check_mark: (alpha) |
| Nginx Ingress Controller | :white_check_mark: (stable) | :x: | :x: | :x: |
| SMI | :white_check_mark: (stable) | :white_check_mark: (stable) | :x: | :x: |
Expand Down
32 changes: 31 additions & 1 deletion docs/features/traffic-management/apisix.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,22 @@ spec:
canaryService: rollout-apisix-canary-canary
stableService: rollout-apisix-canary-stable
trafficRouting:
managedRoutes:
- name: set-header
apisix:
route:
name: rollouts-apisix-route
rules:
- rollouts-apisix
steps:
- setCanaryScale:
replicas: 1
setHeaderRoute:
match:
- headerName: trace
headerValue:
exact: debug
name: set-header
- setWeight: 20
- pause: {}
- setWeight: 40
Expand Down Expand Up @@ -182,5 +192,25 @@ Spec:
Weight: 20
......
```
The `rollout-apisix-canary-canary` service gets 20% traffic through the Apache APISIX.

The `rollout-apisix-canary-canary` service gets 20% traffic through the Apache APISIX.
You can check SetHeader ApisixRoute's match by the following command
```bash
kubectl describe apisixroute set-header

......
Spec:
Http:
Backends:
Service Name: rollout-apisix-canary-canary
Service Port: 80
Weight: 100
Match:
Exprs:
Op: Equal
Subject:
Name: trace
Scope: Header
Value: debug
......
```
11 changes: 11 additions & 0 deletions examples/apisix/rollout.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,23 @@ spec:
canaryService: rollout-apisix-canary-canary
stableService: rollout-apisix-canary-stable
trafficRouting:
managedRoutes:
- name: set-header
apisix:
route:
name: rollouts-apisix-route
rules:
- rollouts-apisix
steps:
- setCanaryScale:
replicas: 1
setHeaderRoute:
match:
- headerName: trace
headerValue:
exact: debug
name: set-header
- pause: { }
- setWeight: 20
- pause: { }
- setWeight: 40
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/rollouts/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const (
// InvalidSetCanaryScaleTrafficPolicy indicates that TrafficRouting, required for SetCanaryScale, is missing
InvalidSetCanaryScaleTrafficPolicy = "SetCanaryScale requires TrafficRouting to be set"
// InvalidSetHeaderRouteTrafficPolicy indicates that TrafficRouting required for SetHeaderRoute is missing
InvalidSetHeaderRouteTrafficPolicy = "SetHeaderRoute requires TrafficRouting, supports Istio and ALB"
InvalidSetHeaderRouteTrafficPolicy = "SetHeaderRoute requires TrafficRouting, supports Istio and ALB and Apisix"
// InvalidSetMirrorRouteTrafficPolicy indicates that TrafficRouting, required for SetCanaryScale, is missing
InvalidSetMirrorRouteTrafficPolicy = "SetMirrorRoute requires TrafficRouting, supports Istio only"
// InvalidStringMatchMultipleValuePolicy indicates that SetCanaryScale, has multiple values set
Expand Down Expand Up @@ -305,7 +305,7 @@ func ValidateRolloutStrategyCanary(rollout *v1alpha1.Rollout, fldPath *field.Pat

if step.SetHeaderRoute != nil {
trafficRouting := rollout.Spec.Strategy.Canary.TrafficRouting
if trafficRouting == nil || (trafficRouting.Istio == nil && trafficRouting.ALB == nil) {
if trafficRouting == nil || (trafficRouting.Istio == nil && trafficRouting.ALB == nil && trafficRouting.Apisix == nil) {
allErrs = append(allErrs, field.Invalid(stepFldPath.Child("setHeaderRoute"), step.SetHeaderRoute, InvalidSetHeaderRouteTrafficPolicy))
} else if step.SetHeaderRoute.Match != nil && len(step.SetHeaderRoute.Match) > 0 {
for j, match := range step.SetHeaderRoute.Match {
Expand Down
Loading