Skip to content

Commit 0217c76

Browse files
committed
Chore: Bring Linkerd GAMMA HTTPRoute example up to date
1 parent 08c4a47 commit 0217c76

File tree

6 files changed

+130
-69
lines changed

6 files changed

+130
-69
lines changed

examples/linkerd-header-based/README.md

Lines changed: 113 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,29 @@
66

77
A Kubernetes cluster. If you do not have one, you can create one using [kind](https://kind.sigs.k8s.io/), [minikube](https://minikube.sigs.k8s.io/), or any other Kubernetes cluster. This guide will use Kind.
88

9-
Linkerd installed in your Kubernetes cluster.
10-
11-
12-
## Step 1 - Create a Kind cluster by running the following command:
9+
## Step 1 - Create a Kind cluster by running the following command
1310

1411
```shell
15-
kind delete cluster &>/dev/null
1612
kind create cluster --config ./kind-cluster.yaml
1713
```
1814

19-
## Step 2 - Install Linkerd and Linkerd Viz by running the following commands:
15+
## Step 2 - Install Linkerd and Linkerd Viz by running the following commands
2016

2117
I will use the Linkerd CLI to install Linkerd in the cluster. You can also install Linkerd using Helm or kubectl.
22-
I tested this guide with Linkerd version 2.14.10
18+
I tested this guide with Linkerd version `edge-25.9.4`.
19+
20+
> [!IMPORTANT]
21+
> Linkerd version `edge-25.9.4` uses `v1` GatewayAPI apiVersion and the [plugin](https://github.com/argoproj-labs/rollouts-plugin-trafficrouter-gatewayapi) `v0.8.0` expects that. It wouldn't work if `v1beta1` GatewayAPI apiVersion CRDs would be installed (like in the case of an older Linkerd `stable-2.14.10`)
2322
2423
```shell
24+
export LINKERD2_VERSION=edge-25.9.4; curl --proto '=https' --tlsv1.2 -sSfL https://run.linkerd.io/install-edge | sh
25+
export PATH=$PATH:/home/baburciu/.linkerd2/bin
26+
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.2.1/standard-install.yaml # Gateway API CRDs must be installed prior to installing Linkerd
2527
linkerd install --crds | kubectl apply -f -
2628
linkerd install | kubectl apply -f - && linkerd check
2729
linkerd viz install | kubectl apply -f - && linkerd check
2830
```
2931

30-
3132
## Step 3 - Install Argo Rollouts and Argo Rollouts plugin to allow Linkerd to manage the traffic:
3233

3334
```shell
@@ -38,7 +39,7 @@ kubectl apply -f argo-rollouts-plugin.yaml
3839
kubectl rollout restart deploy -n argo-rollouts
3940
```
4041

41-
## Step 4 - Grant Argo Rollouts SA access to the Gateway/Http Route
42+
## Step 4 - Grant Argo Rollouts SA access to the HTTPRoute
4243
```shell
4344
kubectl apply -f cluster-role.yaml
4445
```
@@ -51,22 +52,23 @@ kubectl apply -f cluster-role-binding.yaml
5152
```
5253
## Step 5 - Create HTTPRoute that defines a traffic split between two services
5354

54-
Create HTTPRoute and connect to the created Gateway resource
55+
Create a GAMMA [producer `HTTPRoute`](https://gateway-api.sigs.k8s.io/concepts/glossary/#producer-route) resource and connect it to a parent K8s service (using a canary and stable K8s services as backends)
5556

5657
```shell
5758
kubectl apply -f httproute.yaml
5859
```
59-
## Step 6 - Create the services required for traffic split
6060

61-
Create three Services required for canary based rollout stratedy
61+
## Step 6 - Create the services required for traffic split
62+
63+
Create three Services required for canary based rollout strategy
6264

6365
```shell
6466
kubectl apply -f service.yaml
6567
```
6668

67-
## Step 7 - Create the services required for traffic split
69+
## Step 7 - Add `linkerd.io/inject: enabled` annotation to namespace
6870

69-
Add Linkerd annotation to the namespace where the services are deployed
71+
Add Linkerd annotation to the namespace where the pods are deployed to enable [Automatic Proxy Injection](https://linkerd.io/2-edge/features/proxy-injection/)
7072

7173
```shell
7274
kubectl apply -f namespace.yaml
@@ -75,12 +77,15 @@ kubectl apply -f namespace.yaml
7577
## Step 8 - Create an example Rollout
7678

7779
Deploy a rollout to get the initial version.
80+
7881
```shell
7982
kubectl apply -f rollout.yaml
8083
```
8184

8285
## Step 9 - Watch the rollout
83-
Monitor the HTTPRoute configuration to see how traffic is split and header-based routing is configured:
86+
87+
Monitor the HTTPRoute configuration to see how traffic is split and header-based routing is configured
88+
8489
```shell
8590
watch "kubectl get httproute.gateway.networking.k8s.io/argo-rollouts-http-route -o jsonpath='{\" HEADERS: \"}{.spec.rules[*].matches[*]}'"
8691
```
@@ -90,16 +95,102 @@ watch "kubectl get httproute.gateway.networking.k8s.io/argo-rollouts-http-route
9095
kubectl patch rollout rollouts-demo --type='json' -p='[{"op": "replace", "path": "/spec/template/spec/containers/0/env/0/value", "value": "1.1.0"}]'
9196
```
9297

93-
## Step 11 - Test the header-based routing with curl
94-
95-
You can test the header-based routing by sending requests with and without the specified header:
98+
## Step 11 - Observe the rollout and HTTPRoute rule addition of [canary header matching rule](https://gateway-api.sigs.k8s.io/guides/traffic-splitting/#canary-traffic-rollout)
9699

97-
# Without header (goes to stable)
98100
```shell
99-
curl http://localhost:80
101+
$ kubectl argo rollouts promote rollouts-demo # promote to Rollout step 1
102+
$ kubectl argo rollouts get rollout rollouts-demo
103+
Name: rollouts-demo
104+
Namespace: default
105+
Status: ॥ Paused
106+
Message: CanaryPauseStep
107+
Strategy: Canary
108+
Step: 3/5
109+
SetWeight: 0
110+
ActualWeight: 0
111+
Images: hashicorp/http-echo (canary, stable)
112+
Replicas:
113+
Desired: 5
114+
Current: 6
115+
Updated: 1
116+
Ready: 6
117+
Available: 6
118+
119+
NAME KIND STATUS AGE INFO
120+
⟳ rollouts-demo Rollout ॥ Paused 4m53s
121+
├──# revision:2
122+
│ └──⧉ rollouts-demo-8598f766fd ReplicaSet ✔ Healthy 67s canary
123+
│ └──□ rollouts-demo-8598f766fd-2cvt4 Pod ✔ Running 31s ready:2/2
124+
└──# revision:1
125+
└──⧉ rollouts-demo-5d78c448f9 ReplicaSet ✔ Healthy 4m53s stable
126+
├──□ rollouts-demo-5d78c448f9-9zttx Pod ✔ Running 4m53s ready:2/2
127+
├──□ rollouts-demo-5d78c448f9-hpcfg Pod ✔ Running 4m53s ready:2/2
128+
├──□ rollouts-demo-5d78c448f9-l757w Pod ✔ Running 4m53s ready:2/2
129+
├──□ rollouts-demo-5d78c448f9-xl72c Pod ✔ Running 4m53s ready:2/2
130+
└──□ rollouts-demo-5d78c448f9-zk5pd Pod ✔ Running 4m53s ready:2/2
131+
$
132+
$ kubectl get httproute argo-rollouts-http-route -o yaml | yq .spec.rules
133+
- backendRefs:
134+
- group: core
135+
kind: Service
136+
name: argo-rollouts-stable-service
137+
port: 80
138+
weight: 100
139+
- group: core
140+
kind: Service
141+
name: argo-rollouts-canary-service
142+
port: 80
143+
weight: 0
144+
matches:
145+
- path:
146+
type: PathPrefix
147+
value: /
148+
- backendRefs:
149+
- group: ""
150+
kind: Service
151+
name: argo-rollouts-canary-service
152+
port: 80
153+
weight: 0
154+
matches:
155+
- headers:
156+
- name: X-Test
157+
type: Exact
158+
value: test
159+
path:
160+
type: PathPrefix
161+
value: /
162+
```
163+
```shell
164+
$ kubectl run -it --image nicolaka/netshoot:v0.13 network-test -- sh # run a pod to source curl tests
165+
$ kubectl exec -it network-test -c network-test -- sh
166+
~ # # stable K8s service targets any of the 5 stable pods
167+
~ # curl http://argo-rollouts-stable-service/
168+
Hello from rollouts-demo-5d78c448f9-l757w
169+
~ #
170+
~ # # canary K8s service targets the one canary pod, created for the `setCanaryScale` step in the Rollout
171+
~ # curl http://argo-rollouts-canary-service/
172+
Hello from rollouts-demo-8598f766fd-2cvt4
173+
~ #
174+
~ # # GAMMA-type HTTPRoute's `.spec.parentRefs` K8s service only targets stable pods since no `setWeight` step is used in the Rollout
175+
~ # seq 1 100 | xargs -P 10 -I {} bash -c 'curl -s http://argo-rollouts-service' > pods.txt
176+
~ # sort pods.txt | uniq -c | sort -rn
177+
25 Hello from rollouts-demo-5d78c448f9-hpcfg
178+
21 Hello from rollouts-demo-5d78c448f9-xl72c
179+
19 Hello from rollouts-demo-5d78c448f9-zk5pd
180+
19 Hello from rollouts-demo-5d78c448f9-l757w
181+
16 Hello from rollouts-demo-5d78c448f9-9zttx
182+
~ #
100183
```
101184

102-
# With header (goes to canary)
185+
## Step 12 - Test the header-based routing with curl
186+
187+
You can test the header-based routing by sending requests with the specified header.
188+
With header it always goes to canary:
189+
103190
```shell
104-
curl -H "X-test: test" http://localhost:80
191+
$ kubectl exec -it network-test -c network-test -- sh
192+
~ # seq 1 100 | xargs -P 10 -I {} bash -c 'curl -s -H "X-Test: test" http://argo-rollouts-service' > pods.txt
193+
~ # sort pods.txt | uniq -c | sort -rn
194+
100 Hello from rollouts-demo-8598f766fd-2cvt4
195+
~ #
105196
```

examples/linkerd-header-based/argo-rollouts-plugin.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ metadata:
77
data:
88
trafficRouterPlugins: |-
99
- name: "argoproj-labs/gatewayAPI"
10-
location: "https://github.com/argoproj-labs/rollouts-plugin-trafficrouter-gatewayapi/releases/download/v0.2.0/gateway-api-plugin-linux-arm64"
10+
location: "https://github.com/argoproj-labs/rollouts-plugin-trafficrouter-gatewayapi/releases/download/v0.8.0/gatewayapi-plugin-linux-amd64"
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
kind: Cluster
22
apiVersion: kind.x-k8s.io/v1alpha4
3+
name: linkerd-header-based
34
nodes:
45
- role: control-plane
56
kubeadmConfigPatches:
@@ -8,10 +9,3 @@ nodes:
89
nodeRegistration:
910
kubeletExtraArgs:
1011
node-labels: "ingress-ready=true"
11-
extraPortMappings:
12-
- containerPort: 80
13-
hostPort: 80
14-
protocol: TCP
15-
- containerPort: 443
16-
hostPort: 443
17-
protocol: TCP

examples/linkerd-header-based/rollout.yaml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ spec:
1212
trafficRouting:
1313
plugins:
1414
argoproj-labs/gatewayAPI:
15-
httpRoute: argo-rollouts-http-route # our created httproute
16-
namespace: default # namespace where this rollout resides
17-
useHeaderRoutes: true
15+
httpRoutes:
16+
- name: argo-rollouts-http-route
17+
useHeaderRoutes: true
18+
namespace: default
1819
managedRoutes:
1920
- name: argo-rollouts
2021
steps:
@@ -30,7 +31,6 @@ spec:
3031
- pause: {}
3132
- setHeaderRoute: # remove header route
3233
name: argo-rollouts
33-
3434
revisionHistoryLimit: 2
3535
selector:
3636
matchLabels:
@@ -41,20 +41,22 @@ spec:
4141
app: rollouts-demo
4242
spec:
4343
containers:
44-
- name: rollouts-demo
45-
image: argoproj/rollouts-demo:red
44+
- name: http-echo
45+
image: hashicorp/http-echo
46+
args:
47+
- "-text=Hello from $(POD_NAME)"
4648
ports:
4749
- name: http
48-
containerPort: 8080
50+
containerPort: 5678
4951
protocol: TCP
5052
env:
51-
- name: APP_VERSION
52-
value: "1.0.0"
53+
- name: APP_VERSION
54+
value: "1.0"
55+
- name: POD_NAME
56+
valueFrom:
57+
fieldRef:
58+
fieldPath: metadata.name
5359
resources:
5460
requests:
5561
memory: 32Mi
5662
cpu: 5m
57-
58-
59-
60-

examples/linkerd-header-based/setup.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

examples/linkerd-header-based/steps.sh

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)