From 39ecfe8dbda2788facadea9fe3db220664fde084 Mon Sep 17 00:00:00 2001 From: Stephen McCarthy <29098561+smccarthy-ie@users.noreply.github.com> Date: Mon, 13 May 2024 13:58:47 +0100 Subject: [PATCH] docs: add numbering to headers to help navigation and readability (#639) * docs: add numbering to headers to help navigation and readability, minor edits * docs: add line break to fix bullet list format on kuadrant docs site * Update doc/user-guides/secure-protect-connect-single-multi-cluster.md Co-authored-by: Craig Brookes --------- Co-authored-by: Craig Brookes --- doc/install/install-openshift.md | 98 ++++--- ...re-protect-connect-single-multi-cluster.md | 241 ++++++++++-------- doc/user-guides/secure-protect-connect.md | 6 +- 3 files changed, 194 insertions(+), 151 deletions(-) diff --git a/doc/install/install-openshift.md b/doc/install/install-openshift.md index fdb7d9da0..2a4992368 100644 --- a/doc/install/install-openshift.md +++ b/doc/install/install-openshift.md @@ -1,34 +1,39 @@ # Install Kuadrant on an OpenShift cluster -NOTE: You must perform these steps on each cluster that you want to use Kuadrant on. +NOTE: You must perform these steps on each OpenShift cluster that you want to use Kuadrant on. ## Prerequisites -- OpenShift Container Platform 4.14.x or later with community Operator catalog available -- AWS account with Route 53 and zone -- Accessible Redis Instance +- OpenShift Container Platform 4.14.x or later with community Operator catalog available. +- AWS account with Route 53 and zone. +- Accessible Redis instance. -## Set up your environment + +## Procedure + +### Step 1 - Set up your environment ```bash export AWS_ACCESS_KEY_ID=xxxxxxx # Key ID from AWS with Route 53 access -export AWS_SECRET_ACCESS_KEY=xxxxxxx # Access Key from AWS with Route 53 access +export AWS_SECRET_ACCESS_KEY=xxxxxxx # Access key from AWS with Route 53 access export REDIS_URL=redis://user:xxxxxx@some-redis.com:10340 # A Redis cluster URL ``` -## Install the dependencies - -Kuadrant integrates with Istio as a Gateway API provider. Before you can use Kuadrant, you must set up an Istio-based Gateway API provider. For this step, you will use the Sail Operator. +### Step 2 - Install Gateway API v1 -### Install v1 of Gateway API: +Before you can use Kuadrant, you must install Gateway API v1 as follows: ```bash kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/standard-install.yaml ``` -### Install and configure Istio with the Sail Operator +### Step 3 - Install and configure Istio with the Sail Operator + +Kuadrant integrates with Istio as a Gateway API provider. You can set up an Istio-based Gateway API provider by using the Sail Operator. + +#### Install Istio -To install Istio, run the following command: +To install the Istio Gateway provider, run the following commands: ```bash kubectl create ns istio-system @@ -58,7 +63,7 @@ spec: EOF ``` -To check the status of the install, you can run: +Check the status of the installation as follows: ```bash kubectl get installplan -n istio-system -o=jsonpath='{.items[0].status.phase}' @@ -68,6 +73,8 @@ When ready, the status will change from `installing` to `complete`. #### Configure Istio +To configure the Istio Gateway API provider, run the following command: + ```bash kubectl apply -f - <. +- You have a realm, client, and users set up. This example assumes a realm in a Keycloak instance called `toystore`. - Copy the OAS from [sample OAS for rate-limiting and OIDC](../../examples/oas-oidc.yaml) to a local location. -### Set up an OpenID AuthPolicy + +#### Set up an OpenID AuthPolicy + +Set the following environment variables: ```bash export openIDHost=some.keycloak.com export oasPath=examples/oas-oidc.yaml ``` -> **Note:** the sample OAS has some placeholders for namespaces and domains - we will inject valid values into these placeholders based on our previous env vars +NOTE: The sample OAS has some placeholders for namespaces and domains. You will inject valid values into these placeholders based on your previous environment variables. -Let's use our OAS and `kuadrantctl` to generate an `AuthPolicy` to replace the default on the Gateway. +You can use your OAS and `kuadrantctl` to generate an `AuthPolicy` to replace the default on the Gateway as follows: ```bash cat $oasPath | envsubst | kuadrantctl generate kuadrant authpolicy --oas - ``` -If we're happy with the generated resource, let's apply it to the cluster: +If you are happy with the generated resource, you can apply it to the cluster as follows: ```bash cat $oasPath | envsubst | kuadrantctl generate kuadrant authpolicy --oas - | kubectl apply -f - ``` -We should see in the status of the `AuthPolicy` that it has been accepted and enforced: +You should see in the status of the `AuthPolicy` that it has been accepted and enforced: ```bash kubectl get authpolicy -n ${devNS} toystore -o=jsonpath='{.status.conditions}' ``` -On our `HTTPRoute`, we should also see it now affected by this `AuthPolicy` in the toystore namespace: +On your `HTTPRoute`, you should also see it now affected by this `AuthPolicy` in the toystore namespace: ```bash kubectl get httproute toystore -n ${devNS} -o=jsonpath='{.status.parents[0].conditions[?(@.type=="kuadrant.io/AuthPolicyAffected")].message}' ``` -Let's now test our `AuthPolicy`: +#### Test your OpenID AuthPolicy + +You can test your `AuthPolicy` as follows: ```bash export ACCESS_TOKEN=$(curl -k -H "Content-Type: application/x-www-form-urlencoded" \ @@ -569,7 +593,7 @@ export ACCESS_TOKEN=$(curl -k -H "Content-Type: application/x-www-form-urlencode curl -k -XPOST --write-out '%{http_code}\n' --silent --output /dev/null "https://$(kubectl get httproute toystore -n ${devNS} -o=jsonpath='{.spec.hostnames[0]}')/v1/toys" ``` -You should see a `401` response code. Make a request with a valid bearer token: +You should see a `401` response code. Make a request with a valid bearer token as follows: ```bash curl -k -XPOST --write-out '%{http_code}\n' --silent --output /dev/null -H "Authorization: Bearer $ACCESS_TOKEN" "https://$(kubectl get httproute toystore -n ${devNS} -o=jsonpath='{.spec.hostnames[0]}')/v1/toys" @@ -577,32 +601,36 @@ curl -k -XPOST --write-out '%{http_code}\n' --silent --output /dev/null -H "Auth You should see a `200` response code. -### Set up rate limiting +### Step 7 - Set up rate limiting -Lastly, you can generate your `RateLimitPolicy` to add your rate limits, based on your OAS file. Rate limiting is simplified for this walkthrough and is based on either the bearer token or the API key value. There are more advanced examples in the How-to guides on the Kuadrant documentation site, for example: -[Authenticated rate limiting with JWTs and Kubernetes RBAC](https://docs.kuadrant.io/kuadrant-operator/doc/user-guides/authenticated-rl-with-jwt-and-k8s-authnz/) +Lastly, you can generate your `RateLimitPolicy` to add your rate limits, based on your OAS file. Rate limiting is simplified for this walkthrough and is based on either the bearer token or the API key value. There are more advanced examples in the How-to guides on the Kuadrant documentation site, for example: [Authenticated rate limiting with JWTs and Kubernetes RBAC](https://docs.kuadrant.io/kuadrant-operator/doc/user-guides/authenticated-rl-with-jwt-and-k8s-authnz/). You can continue to use this sample OAS document, which includes both authentication and a rate limit: ```bash export oasPath=examples/oas-oidc.yaml + +``` + Again, you should see the rate limit policy accepted and enforced: ```bash kubectl get ratelimitpolicy -n ${devNS} toystore -o=jsonpath='{.status.conditions}' ``` -On your `HTTPoute` we should now see it is affected by the RateLimitPolicy in the same namespace: + +On your `HTTRoute`, you should now see it is affected by the `RateLimitPolicy` in the same namespace: ```bash kubectl get httproute toystore -n ${devNS} -o=jsonpath='{.status.parents[0].conditions[?(@.type=="kuadrant.io/RateLimitPolicyAffected")].message}' ``` -Let's now test your rate-limiting. +#### Test your RateLimitPolicy -Note you may need to wait a minute for the new rate limits to be applied. With the below requests you should see some number of 429 responses. +You can now test your rate limiting as follows: +NOTE: You might need to wait a minute for the new rate limits to be applied. With the following requests, you should see a number of 429 responses. -API Key Auth: +##### API Key auth ```bash for i in {1..3} @@ -612,8 +640,7 @@ curl -XPOST -H 'api_key:secret' -s -k -o /dev/null -w "%{http_code}" "https://$ printf "\n -- \n" done ``` - -And with OpenID Connect Auth: +##### OpenID Connect auth ```bash export ACCESS_TOKEN=$(curl -k -H "Content-Type: application/x-www-form-urlencoded" \ @@ -633,4 +660,4 @@ done ## Conclusion -You've completed the secure, protect, and connect walkthrough. To learn more about Kuadrant, visit https://docs.kuadrant.io +You have completed the secure, protect, and connect walkthrough. To learn more about Kuadrant, visit . diff --git a/doc/user-guides/secure-protect-connect.md b/doc/user-guides/secure-protect-connect.md index 16fba50e6..dc2c4f302 100644 --- a/doc/user-guides/secure-protect-connect.md +++ b/doc/user-guides/secure-protect-connect.md @@ -1,8 +1,8 @@ -# Secure, Protect and Connect services with Kuadrant +# Secure, protect, and connect services with Kuadrant on Kubernetes -## Pre-requisites +## Prerequisites -- Completed the [Single-cluster Quick Start](https://docs.kuadrant.io/getting-started-single-cluster/) or [Multi-cluster Quick Start](https://docs.kuadrant.io/getting-started-multi-cluster/) +- You have completed the [Single-cluster Quick Start](https://docs.kuadrant.io/getting-started-single-cluster/) or [Multi-cluster Quick Start](https://docs.kuadrant.io/getting-started-multi-cluster/). ## Overview