Skip to content

Commit

Permalink
update readme to be more accurate with header based routing
Browse files Browse the repository at this point in the history
  • Loading branch information
AlonGluz committed Dec 13, 2024
1 parent b942bb1 commit 5f5d513
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
22 changes: 19 additions & 3 deletions examples/linkerd-header-based/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Using Linkerd with Argo Rollouts
# Using Linkerd with Argo Rollouts for header based traffic split

[Linkerd](https://linkerd.io/) is a service mesh for Kubernetes. It makes running services easier and safer by giving you runtime debugging, observability, reliability, and security—all without requiring any changes to your code.

Expand All @@ -19,7 +19,7 @@ kind create cluster --config ./kind-cluster.yaml
## Step 2 - Install Linkerd and Linkerd Viz by running the following commands:

I will use the Linkerd CLI to install Linkerd in the cluster. You can also install Linkerd using Helm or kubectl.
I tested this guide with Linkerd version 2.13.0
I tested this guide with Linkerd version 2.14.10

```shell
linkerd install --crds | kubectl apply -f -
Expand Down Expand Up @@ -80,13 +80,29 @@ kubectl apply -f rollout.yaml
```

## Step 9 - Watch the rollout
Monitor the HTTPRoute configuration to see how traffic is split and header-based routing is configured:
```shell
watch "kubectl -n default get httproute.gateway.networking.k8s.io/argo-rollouts-http-route -o custom-columns=NAME:.metadata.name,PRIMARY_SERVICE:.spec.rules[0].backendRefs[0].name,PRIMARY_WEIGHT:.spec.rules[0].backendRefs[0].weight,CANARY_SERVICE:.spec.rules[0].backendRefs[1].name,CANARY_WEIGHT:.spec.rules[0].backendRefs[1].weight"
watch "kubectl get httproute.gateway.networking.k8s.io/argo-rollouts-http-route -o jsonpath='{\" HEADERS: \"}{.spec.rules[*].matches[*]}'"
```

## Step 10 - Patch the rollout to see the canary deployment
```shell
kubectl patch rollout rollouts-demo --type='json' -p='[{"op": "replace", "path": "/spec/template/spec/containers/0/env/0/value", "value": "1.1.0"}]'
```

## Step 11 - Test the header-based routing with curl

You can test the header-based routing by sending requests with and without the specified header:

# Without header (goes to stable)
```shell
curl -H "Host: rollout.example.com" http://localhost:80
```

# With header (goes to canary)
```shell
curl -H "Host: rollout.example.com" -H "X-test: canary" http://localhost:80
```

You should see different responses from the stable and canary versions based on the presence of the `X-test: canary` header.

10 changes: 8 additions & 2 deletions examples/linkerd-header-based/rollout.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,21 @@ spec:
httpRoute: argo-rollouts-http-route # our created httproute
namespace: default # namespace where this rollout resides
useHeaderRoutes: true
managedRoutes:
- name: argo-rollouts
steps:
- pause: {}
- setCanaryScale:
replicas: 1
- setHeaderRoute:
name: header-route
name: argo-rollouts
match:
- headerName: X-Test
headerValue:
exact: test
- pause: {}
- setHeaderRoute: # remove header route
name: header-route
name: argo-rollouts

revisionHistoryLimit: 2
selector:
Expand All @@ -52,3 +54,7 @@ spec:
requests:
memory: 32Mi
cpu: 5m




0 comments on commit 5f5d513

Please sign in to comment.