diff --git a/README.md b/README.md index 5b5dcc7..c95a5fc 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,9 @@ * [Overview](#overview) * [CustomResourceDefinitions](#customresourcedefinitions) * [Getting started](#getting-started) +* [Demos](#demos) + * [Updating the RateLimitPolicy `targetRef` attribute](/doc/demo-rlp-update-targetref.md) + * [Authenticated rate limiting](/doc/demo-rlp-authenticated.md) * [Contributing](#contributing) * [Licensing](#licensing) @@ -240,7 +243,7 @@ To verify creation: ``` kubectl get authorizationpolicy -A NAMESPACE NAME AGE -kuadrant-system on-kuadrant-gwapi-gateway-using-hr-toystore 3m36s +kuadrant-system on-kuadrant-gwapi-gateway-using-toystore-custom 81s ``` 9.- Verify authentication @@ -257,6 +260,18 @@ Should return `200 OK` curl -v -H 'Host: api.toystore.com' -H 'Authorization: APIKEY ALICEKEYFORDEMO' -X POST http://localhost:9080/admin/toy ``` +## Demos + +### [Updating the RateLimitPolicy `targetRef` attribute](/doc/demo-rlp-update-targetref.md) + +This demo shows how the kuadrant's controller applies the rate limit policy to the new HTTPRoute +object and cleans up rate limit configuration to the HTTPRoute object no longer referenced by the policy. + +### [Authenticated rate limiting](/doc/demo-rlp-authenticated.md) + +This demo shows how to configure rate limiting after authentication stage and rate limit configuration +is per API key basis. + ## Contributing The [Development guide](doc/development.md) describes how to build the kuadrant controller and diff --git a/controllers/apim/httproute_controller.go b/controllers/apim/httproute_controller.go index f7c37d9..e4b1a3b 100644 --- a/controllers/apim/httproute_controller.go +++ b/controllers/apim/httproute_controller.go @@ -55,7 +55,7 @@ func (r *HTTPRouteReconciler) Reconcile(eventCtx context.Context, req ctrl.Reque gwName := string(parentRef.Name) authPolicy := &istiosecurityv1beta1.AuthorizationPolicy{} - authPolicy.SetName(getAuthPolicyName(gwName, httproute.Name, "")) // TODO(rahul): need to do something about this controller + authPolicy.SetName(getAuthPolicyName(gwName, httproute.Name, "custom")) // TODO(rahul): need to do something about this controller authPolicy.SetNamespace(gwNamespace) common.TagObjectToDelete(authPolicy) err := r.ReconcileResource(ctx, &istiosecurityv1beta1.AuthorizationPolicy{}, authPolicy, nil) @@ -161,7 +161,7 @@ func (r *HTTPRouteReconciler) reconcileAuthPolicy(ctx context.Context, logger lo authPolicy := istiosecurityv1beta1.AuthorizationPolicy{ ObjectMeta: metav1.ObjectMeta{ - Name: getAuthPolicyName(gwName, hr.Name, ""), + Name: getAuthPolicyName(gwName, hr.Name, "custom"), Namespace: gwNamespace, }, Spec: authPolicySpec, diff --git a/doc/demo-rlp-authenticated.md b/doc/demo-rlp-authenticated.md new file mode 100644 index 0000000..f96c8e6 --- /dev/null +++ b/doc/demo-rlp-authenticated.md @@ -0,0 +1,150 @@ +## Authenticated rate limiting + +This demo shows how to configure rate limiting after authentication stage and rate limit configuration +is per API key basis. + +### Steps + +Create local cluster and deploy kuadrant + +``` +make local-setup +``` + +Deploy toystore example deployment + +``` +kubectl apply -f examples/toystore/toystore.yaml +``` + +Create `toystore` HTTPRoute to configure routing to the toystore service + +```yaml +kubectl apply -f - <