Skip to content

Commit

Permalink
Merge pull request #5 from ilrudie/setHeaderRoute
Browse files Browse the repository at this point in the history
initial implementation of setHeaderRoute behavior
  • Loading branch information
Sodman authored Oct 31, 2024
2 parents 4318968 + 5c85bd9 commit 08087e4
Show file tree
Hide file tree
Showing 11 changed files with 705 additions and 571 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches:
- "main"
env:
GOLANG_VERSION: '1.19'
GOLANG_VERSION: '1.23'

jobs:
unit-tests:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version: '1.23'
cache-dependency-path: go.sum

- name: Release building
Expand All @@ -22,4 +22,4 @@ jobs:
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: ./dist/glooplatform-api-plugin-*
files: ./dist/glooplatform-api-plugin-*
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19 as build
FROM golang:1.23 as build

WORKDIR /src

Expand All @@ -22,4 +22,4 @@ FROM quay.io/argoproj/argo-rollouts:v1.5.1

COPY --from=build /src/main /home/argo-rollouts/glooplatform-api-plugin

ENTRYPOINT ["/bin/rollouts-controller"]
ENTRYPOINT ["/bin/rollouts-controller"]
52 changes: 50 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,21 @@ The plugin can be loaded into the controller runtime by building your own Argo R

See [Kustomize patches](./deploy/kustomization.yaml) in this repo for Argo Rollouts configuration examples.

### Usage
### Canary Rollouts

As of version 0.0.0-beta3 support for header-based routing has been added to the original weighted routing features.

When defining your RouteTable you must define at least a HTTPRoute (under .spec.http) which contains a 'forwardTo' destination for your stable/active service. The plugin will attempt to derive your canary destination from the stable destination if you do not define the canary destination yourself in your RouteTable. This is could lead to incorrect config if your canary service differs significantly from your stable service. This can be handled by defining the canary service in your RouteTable but setting it's weight to 0 and the weight of your stable to 100.

Canary and stable services in the Rollout spec must refer to `forwardTo` destinations in [routes](https://docs.solo.io/gloo-mesh-enterprise/latest/troubleshooting/gloo/routes/) that exist in one or more Gloo Platform RouteTables.

RouteTable and route selection is specified in the plugin config. Either a RouteTable label selector or a named RouteTable must be specified. RouteSelector is entirely optional; this is useful to limit matches to specific routes in a RouteTable if it contains any references to canary or stable services that you do not want to modify.


#### Weighted Routing

Weighted Routing allows you to define one or more steps, which can include actions such as changing the canary service's weight or pausing the rollout.

```yaml
strategy:
canary:
Expand All @@ -79,7 +88,46 @@ RouteTable and route selection is specified in the plugin config. Either a Route
route: demo-preview
# (optional) select a specific route by name
# name: route-name
steps:
- setWeight: 25
- pause: {}
- setWeight: 100
```
#### Header-based Canary Routing
By defining a setHeaderRoute step in your canary rollout strategy you can instruct this plugin to crate a new routeTable route which will route to the canary destination when the header match is satisfied. This feature requires configuring managedRoutes, which grants the plugin ownership over all routes in the routeTable which have the same name. Caution should be used when adding a name to this list because the plugin may overwrite and/or delete any routes it is allowed to manage as needed to implement the behavior specifid in the setHeaderRoute step.
```yaml
strategy:
canary:
canaryService: canary
stableService: stable
trafficRouting:
# managedRoutes are required for using setHeaderRoute
# routes specified here are owned by the plugin
# the plugin will create/delete these routes as needed
# do not specify routes which are already otherwise in use under this field
managedRoutes:
- name: header-canary
plugins:
# the plugin name must match the name used in argo-rollouts-config ConfigMap
solo-io/glooplatform:
routeTableSelector:
labels:
app: demo
namespace: gloo-mesh
steps:
- setHeaderRoute:
match:
- headerName: version
headerValue:
exact: canary
name: header-canary
- pause: {}
- setWeight: 100
```
### Supported Gloo Platform Versions
* All Gloo Platform versions 2.0 and newer
Expand All @@ -91,4 +139,4 @@ RouteTable and route selection is specified in the plugin config. Either a Route
- unit tests
- update tests with mock gloo client using interfaces in [./pkg/gloo/client.go](./pkg/gloo/client.go)
- add more tests
- replace demo api in examples folder w/ https://github.com/argoproj/rollouts-demo images (blue, green, red, etc.)
- replace demo api in examples folder w/ https://github.com/argoproj/rollouts-demo images (blue, green, red, etc.)
52 changes: 52 additions & 0 deletions examples/2-rollout-setHeaderRoute/rollout.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: gloo-rollouts-demo
namespace: gloo-rollouts-demo
spec:
replicas: 1
selector:
matchLabels:
app: gloo-rollouts-demo
template:
metadata:
labels:
app: gloo-rollouts-demo
spec:
containers:
- image: argoproj/rollouts-demo:blue
imagePullPolicy: IfNotPresent
name: gloo-rollouts-demo
ports:
- containerPort: 8080
resources:
limits:
cpu: 100m
memory: 100Mi
strategy:
canary:
canaryService: canary
stableService: stable
trafficRouting:
# managedRoutes are required for using setHeaderRoute
# routes specified here are owned by the plugin
# the plugin will create/delete these routes as needed
# do not specify routes which are already otherwise in use under this field
managedRoutes:
- name: header-canary
plugins:
solo-io/glooplatform:
routeTableSelector:
labels:
app: demo
namespace: gloo-mesh
steps:
- setWeight: 10
- setHeaderRoute:
match:
- headerName: version
headerValue:
exact: canary
name: header-canary
- pause: {}
- setWeight: 100
117 changes: 58 additions & 59 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,96 +1,94 @@
module github.com/argoproj-labs/rollouts-plugin-trafficrouter-glooplatform

go 1.19
go 1.23

require (
github.com/PaesslerAG/gval v1.2.2
github.com/PaesslerAG/jsonpath v0.1.1
github.com/argoproj/argo-rollouts v1.5.1
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
github.com/hashicorp/go-plugin v1.4.9
github.com/sirupsen/logrus v1.9.0
github.com/solo-io/solo-apis v1.6.32-0.20230623162622-377f95c0a7c7
github.com/stretchr/testify v1.8.2
k8s.io/apimachinery v0.26.4
k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible
sigs.k8s.io/controller-runtime v0.14.6
github.com/sirupsen/logrus v1.9.3
github.com/solo-io/solo-apis v1.6.32-0.20240925114939-9e6df5259d8e
github.com/stretchr/testify v1.9.0
k8s.io/apimachinery v0.30.1
k8s.io/client-go v0.30.1
sigs.k8s.io/controller-runtime v0.18.5
)

require (
dario.cat/mergo v1.0.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cncf/xds/go v0.0.0-20230105202645-06c439db220b // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.10.1 // indirect
github.com/envoyproxy/go-control-plane v0.11.1-0.20230202164348-98e9e8eacc1a // indirect
github.com/envoyproxy/protoc-gen-validate v0.9.1 // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cncf/xds/go v0.0.0-20240329184929-0c46c01016dc // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.12.0 // indirect
github.com/envoyproxy/go-control-plane v0.12.1-0.20240415211714-57c85e1829e6 // indirect
github.com/envoyproxy/protoc-gen-validate v1.0.4 // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.1 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/go-task/slim-sprig v2.20.0+incompatible // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/go-hclog v0.14.1 // indirect
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/imdario/mergo v1.0.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.19.1 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.53.0 // indirect
github.com/prometheus/procfs v0.15.0 // indirect
github.com/rotisserie/eris v0.5.4 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/solo-io/cue v0.4.7 // indirect
github.com/solo-io/go-utils v0.24.2 // indirect
github.com/solo-io/protoc-gen-ext v0.0.18 // indirect
github.com/solo-io/skv2 v0.30.2 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/oauth2 v0.5.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/term v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/time v0.3.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230223222841-637eb2293923 // indirect
google.golang.org/grpc v1.54.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
github.com/solo-io/go-utils v0.25.3 // indirect
github.com/solo-io/protoc-gen-ext v0.0.24 // indirect
github.com/solo-io/skv2 v0.40.5 // indirect
github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/term v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240610135401-a8a62080eff3 // indirect
google.golang.org/grpc v1.64.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.26.4 // indirect
k8s.io/component-base v0.26.4 // indirect
k8s.io/klog/v2 v2.80.1 // indirect
k8s.io/kube-openapi v0.0.0-20230109183929-3758b55a6596 // indirect
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 // indirect
k8s.io/api v0.30.1 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/kube-openapi v0.0.0-20240423202451-8948a665c108 // indirect
k8s.io/utils v0.0.0-20240423183400-0849a56e8f22 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

replace (
Expand All @@ -101,6 +99,8 @@ replace (

// anyvendor (used in check-code-gen in CI) requires version v5.3.0, but solo-io/go-utils overrides it
github.com/go-git/go-git/v5 => github.com/go-git/go-git/v5 v5.3.0

github.com/imdario/mergo => dario.cat/mergo v1.0.0
github.com/miekg/dns => github.com/cilium/dns v1.1.4-0.20190417235132-8e25ec9a0ff3
github.com/optiopay/kafka => github.com/cilium/kafka v0.0.0-20180809090225-01ce283b732b

Expand All @@ -111,5 +111,4 @@ replace (
// as to why we are using a private fork.
go.universe.tf/metallb => github.com/cilium/metallb v0.1.1-0.20210831235406-48667b93284d

k8s.io/client-go => k8s.io/client-go v0.26.4
)
Loading

0 comments on commit 08087e4

Please sign in to comment.