Skip to content
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
380 changes: 380 additions & 0 deletions examples/agentgateway/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,380 @@
# Using agentgateway with Argo Rollouts

This guide will describe how to use agentgateway Kubernetes Gateway as an implementation
for the Gateway API in order to do split traffic with Argo Rollouts.

Versions used in this guide:
- Kubernetes Gateway API: v1.5.0
- agentgateway: v1.0.1
- argo-rollouts: v1.8.4
- rollouts-plugin-trafficrouter-gatewayapi: v0.11.0

Dependency:
- [argo rollouts](https://argo-rollouts.readthedocs.io/en/stable/installation/#kubectl-plugin-installation) kubectl plugin

## Step 1 - Install agentgateway and Argo Rollouts

### 1 - Install agentgateway
This installation creates a `agentgateway` GatewayClass, which you will use later. You can follow the instructions below to install via Helm, or refer to the [installation instructions](https://agentgateway.dev/docs/kubernetes/main/install/) for other methods.

1. Install the custom resources of the Kubernetes Gateway API version 1.5.0.
```shell
kubectl apply --server-side -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.5.0/standard-install.yaml
```

Example output:
```shell
customresourcedefinition.apiextensions.k8s.io/gatewayclasses.gateway.networking.k8s.io created
customresourcedefinition.apiextensions.k8s.io/gateways.gateway.networking.k8s.io created
customresourcedefinition.apiextensions.k8s.io/httproutes.gateway.networking.k8s.io created
customresourcedefinition.apiextensions.k8s.io/referencegrants.gateway.networking.k8s.io created
customresourcedefinition.apiextensions.k8s.io/grpcroutes.gateway.networking.k8s.io created
```

2. Deploy the agentgateway CRDs by using Helm. This command creates the agentgateway-system namespace and creates the agentgateway CRDs in the cluster.
```shell
helm upgrade -i --create-namespace \
--namespace agentgateway-system \
--version v1.0.1 agentgateway-crds oci://cr.agentgateway.dev/charts/agentgateway-crds
```

3. Install the agentgateway Helm chart.
```shell
helm upgrade -i -n agentgateway-system agentgateway oci://cr.agentgateway.dev/charts/agentgateway \
--version v1.0.1
```

Example output:
```shell
NAME: agentgateway
LAST DEPLOYED: Thu Feb 13 14:03:51 2025
NAMESPACE: agentgateway-system
STATUS: deployed
REVISION: 1
TEST SUITE: None
```

4. Verify that the control plane is up and running.
```shell
kubectl get pods -n agentgateway-system
```

Example output:
```shell
NAME READY STATUS RESTARTS AGE
agentgateway-78658959cd-cz6jt 1/1 Running 0 12s
```

5. Verify that the agentgateway GatewayClass is created.
```shell
kubectl get gatewayclass agentgateway
```

Example output:
```shell
NAME CONTROLLER ACCEPTED AGE
agentgateway agentgateway.dev/agentgateway True 6m36s
```

### 2 - Install Argo Rollouts
Make sure you also install Argo Rollouts. Follow the [agentgateway Argo Rollouts integration guide](https://agentgateway.dev/docs/kubernetes/main/integrations/argo/#install-argo-rollouts) to install Argo Rollouts.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This page throws a 404 for me. Why was it unpublished?


## Step 2 - Split traffic with Gateway resources

Create a dedicated gateway that splits traffic across your Argo Rollouts resources.

1. Create a Gateway.
```yaml
kubectl apply -f - <<EOF
apiVersion: gateway.networking.k8s.io/v1beta1
kind: Gateway
metadata:
name: argo-rollouts-gateway
namespace: argo-rollouts
spec:
gatewayClassName: agentgateway
listeners:
- protocol: HTTP
name: http
port: 80
EOF
```

2. Create and attach an HTTPRoute to the Gateway.
```yaml
kubectl apply -f - <<EOF
apiVersion: gateway.networking.k8s.io/v1beta1
kind: HTTPRoute
metadata:
name: argo-rollouts-http-route
namespace: argo-rollouts
spec:
parentRefs:
- name: argo-rollouts-gateway
namespace: argo-rollouts
rules:
- matches:
backendRefs:
- name: argo-rollouts-stable-service
port: 80
- name: argo-rollouts-canary-service
port: 80
EOF
```

## Step 3 - Create Services for your application

1. Create a canary service.
```yaml
kubectl apply -f - <<EOF
apiVersion: v1
kind: Service
metadata:
name: argo-rollouts-canary-service
namespace: argo-rollouts
spec:
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app: rollouts-demo
EOF
```

2. Create a stable service.
```yaml
kubectl apply -f - <<EOF
apiVersion: v1
kind: Service
metadata:
name: argo-rollouts-stable-service
namespace: argo-rollouts
spec:
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app: rollouts-demo
EOF
```

## Step 4 - Grant argo-rollouts permissions

Grant argo-rollouts permissions to view and modify Gateway HTTPRoute resources. The argo-rollouts service account needs the ability to be able to view and modify HTTPRoutes and Configmaps as well as its existing permissions. Edit the `argo-rollouts` cluster role to add the following permissions or use the RBAC example provided in the [agentgateway documentation](https://agentgateway.dev/docs/kubernetes/main/integrations/argo/#create-rbac-rules-for-argo):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again this throws 404


1. Create a ClusterRole.
```yaml
kubectl apply -f- <<EOF
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: gateway-controller-role
namespace: argo-rollouts
rules:
- apiGroups:
- "gateway.networking.k8s.io"
resources:
- "httproutes"
verbs:
- get
- list
- watch
- update
- patch
- apiGroups:
- ""
resources:
- "configmaps"
verbs:
- get
- list
- watch
- create
- update
- patch
- delete
EOF
```

2. Create a ClusterRoleBinding.
```yaml
kubectl apply -f- <<EOF
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: gateway-admin
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: gateway-controller-role
subjects:
- namespace: argo-rollouts
kind: ServiceAccount
name: argo-rollouts
EOF
```

## Step 5 - Create argo-rollouts resources

1. Create the argo-rollouts resources.
```yaml
kubectl apply -f - <<EOF
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: rollouts-demo
namespace: argo-rollouts
spec:
replicas: 5
strategy:
canary:
canaryService: argo-rollouts-canary-service # our created canary service
stableService: argo-rollouts-stable-service # our created stable service
trafficRouting:
plugins:
argoproj-labs/gatewayAPI:
httpRoute: argo-rollouts-http-route # our created httproute
namespace: argo-rollouts # namespace where this rollout resides
steps:
- setWeight: 30
- pause: {}
- setWeight: 40
- pause: { duration: 10 }
- setWeight: 60
- pause: { duration: 10 }
- setWeight: 80
- pause: { duration: 10 }
revisionHistoryLimit: 2
selector:
matchLabels:
app: rollouts-demo
template:
metadata:
labels:
app: rollouts-demo
spec:
containers:
- name: rollouts-demo
image: argoproj/rollouts-demo:red
ports:
- name: http
containerPort: 8080
protocol: TCP
resources:
requests:
memory: 32Mi
cpu: 5m
EOF
```

## Step 6 - Test Application

1. Port-forward the Gateway service.
```
kubectl port-forward svc/argo-rollouts-gateway 8080:80 -n argo-rollouts
```

2. You can now test the application. An argo application shows up with red dots.
- Via browser:
```shell
http://localhost:8080
```

- Or via terminal:
```shell
curl http://localhost:8080/
curl http://localhost:8080/color
```

## Step 7 - Test the promotion

1. Update the Image of the rollout to blue or a different color.
```shell
kubectl argo rollouts set image rollouts-demo rollouts-demo=argoproj/rollouts-demo:blue -n argo-rollouts
```

Or update the image under containers in rollout.yml to blue or a different color (such as `image: argoproj/rollouts-demo:blue`) and apply the `rollout.yaml` again.
```yaml
kubectl apply -f - <<EOF
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: rollouts-demo
namespace: argo-rollouts
spec:
replicas: 5
strategy:
canary:
canaryService: argo-rollouts-canary-service # our created canary service
stableService: argo-rollouts-stable-service # our created stable service
trafficRouting:
plugins:
argoproj-labs/gatewayAPI:
httpRoute: argo-rollouts-http-route # our created httproute
namespace: argo-rollouts # namespace where this rollout resides
steps:
- setWeight: 30
- pause: {}
- setWeight: 40
- pause: { duration: 10 }
- setWeight: 60
- pause: { duration: 10 }
- setWeight: 80
- pause: { duration: 10 }
revisionHistoryLimit: 2
selector:
matchLabels:
app: rollouts-demo
template:
metadata:
labels:
app: rollouts-demo
spec:
containers:
- name: rollouts-demo
image: argoproj/rollouts-demo:blue # Change the image here.
ports:
- name: http
containerPort: 8080
protocol: TCP
resources:
requests:
memory: 32Mi
cpu: 5m
EOF
```

2. Check the weight difference between the stable and canary service.
```shell
kubectl get httproute argo-rollouts-http-route -o yaml -n argo-rollouts
```

Or use the following command to watch the promotion progress in real time. Make sure you have installed the [argo-rollouts](https://argo-rollouts.readthedocs.io/en/stable/installation/#kubectl-plugin-installation) extension for kubectl.
```shell
kubectl argo rollouts get rollout rollouts-demo -n argo-rollouts --watch
```

3. Promote the rollout. Make sure you have installed the [argo-rollouts](https://argo-rollouts.readthedocs.io/en/stable/installation/#kubectl-plugin-installation) extension for kubectl. Blue and red dots reflect the traffic split in the GUI, run the promotion multiple times until only blue dots remain.
```shell
kubectl argo rollouts promote rollouts-demo -n argo-rollouts
```

4. Check again the weight difference between the stable and canary service.
```shell
kubectl get httproute argo-rollouts-http-route -o yaml -n argo-rollouts
```

5. Verify changes. Now blue dots appear in the web GUI instead of red ones.
- Via browser:
```shell
http://localhost:8080
```

- Or via terminal:
```shell
curl http://localhost:8080/color
```
13 changes: 13 additions & 0 deletions examples/agentgateway/canary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: argo-rollouts-canary-service
namespace: argo-rollouts
spec:
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app: rollouts-demo
Loading
Loading