Skip to content

Commit

Permalink
feat: Traefik support. Fixes #516 (#1907)
Browse files Browse the repository at this point in the history
* Make Traefik suppurt

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Make Traefik suppurt

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Make Traefik suppurt

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Traefik support

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Traefik support

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Update traefik

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Implement traefil support

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* make codegen

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Refactor

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Add traefik tests

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Goimports

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Refactor

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Add test to trafiicrouting_test.go

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Remove added test to trafficrouting_test.go

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Refactor

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Refactor

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Generate new files

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Make codegen

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Add tests

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Add tests

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Add tests

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Add test

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Change tests

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Add mocks

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Add tests

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Add tests

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Change go.yml

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Refactor

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Back apimachinery package version

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Revert "Back apimachinery package version"

This reverts commit 34c61b8.

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Fix

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Bump

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Refactor

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Add field doc

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Make codegen

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Removew verifyWeight and add permissions

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Back go.yml

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Back go.yml

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Change manifests

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Refactor

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Fix tests

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Add tests

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Add test

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Bump

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Add documentation

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Refactor

Signed-off-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>

* Refactor

Signed-off-by: PhilippPlotnikov <philipp.plotnikov@codefresh.io>

* Bump

Signed-off-by: PhilippPlotnikov <philipp.plotnikov@codefresh.io>

* Refactor

Signed-off-by: PhilippPlotnikov <philipp.plotnikov@codefresh.io>

* Bump

Signed-off-by: PhilippPlotnikov <philipp.plotnikov@codefresh.io>

* Bump

Signed-off-by: PhilippPlotnikov <philipp.plotnikov@codefresh.io>

Co-authored-by: PhilippPlotnikov <70917163+PhilippDeveloper@users.noreply.github.com>
  • Loading branch information
PhilippPlotnikov and Philipp-Plotnikov authored Apr 29, 2022
1 parent f91e3ba commit b115ea8
Show file tree
Hide file tree
Showing 17 changed files with 1,524 additions and 455 deletions.
101 changes: 101 additions & 0 deletions docs/features/traffic-management/traefik.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Traefik

The [TraefikService](https://doc.traefik.io/traefik/routing/providers/kubernetes-crd/#kind-traefikservice) is the object supports the ability for [weighted round robin load balancing](https://doc.traefik.io/traefik/routing/providers/kubernetes-crd/#weighted-round-robin) and (traffic mirroring)[https://doc.traefik.io/traefik/routing/providers/kubernetes-crd/#mirroring] when using Traefik as ingress.

## How to integrate TraefikService with Argo Rollouts using it as weighted round robin load balancer

Firstly, we need to create the TraefikService object using its ability for weighted round robin load balancing.

```yaml
apiVersion: traefik.containo.us/v1alpha1
kind: TraefikService
metadata:
name: traefik-service
spec:
weighted:
services:
- name: stable-rollout # k8s service name that you need to create for stable application version
port: 80
- name: canary-rollout # k8s service name that you need to create for new application version
port: 80
```
Notice, we don't specify the `weight` field. It is necessary to be synced with ArgoCD. If we specify this field and Argo Rollouts controller will change it, ArgoCD controller will notice it and will show that this resource is out of sync.

Secondly, we need to create the Argo Rollouts controller.

```yaml
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: rollouts-demo
spec:
replicas: 5
strategy:
canary:
canaryService: canary-rollout
stableService: stable-rollout
trafficRouting:
traefik:
weightedTraefikServiceName: traefik-service # specify traefikService resource name that we have created before
steps:
- setWeight: 30
- pause: {}
- setWeight: 40
- pause: {duration: 10}
- setWeight: 60
- pause: {duration: 10}
- setWeight: 80
- pause: {duration: 10}
...
```

## How to integrate TraefikService with Argo Rollouts using it as traffic mirror

Firstly, we also need to create the TraefikService object but using its ability for traffic mirroring.

```yaml
apiVersion: traefik.containo.us/v1alpha1
kind: TraefikService
metadata:
name: traefik-service
spec:
mirroring:
name: some-service
port: 80
mirrors:
- name: stable-rollout # k8s service name that you need to create for stable application version
port: 80
- name: canary-rollout # k8s service name that you need to create for new application version
port: 80
```

Notice, we don't specify the `percent` field. It is necessary to be synced with ArgoCD. If we specify this field and Argo Rollouts controller will change it, ArgoCD controller will notice it and will show that this resource is out of sync.

Secondly, we need to create the Argo Rollouts controller.

```yaml
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: rollouts-demo
spec:
replicas: 5
strategy:
canary:
canaryService: canary-rollout
stableService: stable-rollout
trafficRouting:
traefik:
mirrorTraefikServiceName: traefik-service # specify traefikService resource name that we have created before
steps:
- setWeight: 30
- pause: {}
- setWeight: 40
- pause: {duration: 10}
- setWeight: 60
- pause: {duration: 10}
- setWeight: 80
- pause: {duration: 10}
...
```
7 changes: 7 additions & 0 deletions manifests/crds/rollout-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,13 @@ spec:
trafficSplitName:
type: string
type: object
traefik:
properties:
weightedTraefikServiceName:
type: string
required:
- weightedTraefikServiceName
type: object
type: object
type: object
type: object
Expand Down
15 changes: 15 additions & 0 deletions manifests/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11721,6 +11721,13 @@ spec:
trafficSplitName:
type: string
type: object
traefik:
properties:
weightedTraefikServiceName:
type: string
required:
- weightedTraefikServiceName
type: object
type: object
type: object
type: object
Expand Down Expand Up @@ -14534,6 +14541,14 @@ rules:
- list
- update
- patch
- apiGroups:
- traefik.containo.us
resources:
- traefikservices
verbs:
- watch
- get
- update
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down
15 changes: 15 additions & 0 deletions manifests/namespace-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11721,6 +11721,13 @@ spec:
trafficSplitName:
type: string
type: object
traefik:
properties:
weightedTraefikServiceName:
type: string
required:
- weightedTraefikServiceName
type: object
type: object
type: object
type: object
Expand Down Expand Up @@ -14534,6 +14541,14 @@ rules:
- list
- update
- patch
- apiGroups:
- traefik.containo.us
resources:
- traefikservices
verbs:
- watch
- get
- update
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down
11 changes: 8 additions & 3 deletions manifests/role/argo-rollouts-clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ rules:
- list
- update
- patch



- apiGroups:
- traefik.containo.us
resources:
- traefikservices
verbs:
- watch
- get
- update
14 changes: 14 additions & 0 deletions pkg/apiclient/rollout/rollout.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1524,6 +1524,10 @@
"appMesh": {
"$ref": "#/definitions/github.com.argoproj.argo_rollouts.pkg.apis.rollouts.v1alpha1.AppMeshTrafficRouting",
"title": "AppMesh holds specific configuration to use AppMesh to route traffic"
},
"traefik": {
"$ref": "#/definitions/github.com.argoproj.argo_rollouts.pkg.apis.rollouts.v1alpha1.TraefikTrafficRouting",
"title": "Traefik holds specific configuration to use Traefik to route traffic"
}
},
"title": "RolloutTrafficRouting hosts all the different configuration for supported service meshes to enable more fine-grained traffic routing"
Expand Down Expand Up @@ -1592,6 +1596,16 @@
},
"description": "TLSRoute holds the information on the virtual service's TLS/HTTPS routes that are desired to be matched for changing weights."
},
"github.com.argoproj.argo_rollouts.pkg.apis.rollouts.v1alpha1.TraefikTrafficRouting": {
"type": "object",
"properties": {
"weightedTraefikServiceName": {
"type": "string",
"title": "TraefikServiceName refer to the name of the Traefik service used to route traffic to the service"
}
},
"title": "TraefikTrafficRouting defines the configuration required to use Traefik as traffic router"
},
"github.com.argoproj.argo_rollouts.pkg.apis.rollouts.v1alpha1.TrafficWeights": {
"type": "object",
"properties": {
Expand Down
Loading

0 comments on commit b115ea8

Please sign in to comment.