Skip to content

Commit

Permalink
refactor: include gateway creation as part of guide
Browse files Browse the repository at this point in the history
Signed-off-by: KevFan <[email protected]>
  • Loading branch information
KevFan committed Dec 5, 2024
1 parent 2d3fa67 commit 983490d
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions doc/user-guides/auth/anonymous-access.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,29 @@ Learn how to allow anonymous access to certain endpoints using Kuadrant's `AuthP

## Prerequisites

You have installed Kuadrant in a [kubernetes](https://docs.kuadrant.io/latest/kuadrant-operator/doc/install/install-kubernetes/) or [OpenShift](https://docs.kuadrant.io/latest/kuadrant-operator/doc/install/install-openshift/) cluster.
You have installed Kuadrant in a [kubernetes](https://docs.kuadrant.io/latest/kuadrant-operator/doc/install/install-kubernetes/) or [OpenShift](https://docs.kuadrant.io/latest/kuadrant-operator/doc/install/install-openshift/) cluster with a Gateway provider.

### Create Gateway
Create a `Gateway` resource for this guide:

```sh
kubectl apply -f -<<EOF
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: kuadrant-ingressgateway
spec:
gatewayClassName: istio
listeners:
- name: http
protocol: HTTP
port: 80
allowedRoutes:
namespaces:
from: Same
EOF
```
The `Gateway` resource created above uses Istio as the gateway provider. For Envoy Gateway, use the Envoy Gateway `GatewayClass` as the `gatewayClassName`.

### Deploy Toy Store application

Expand All @@ -27,7 +49,7 @@ metadata:
spec:
parentRefs:
- name: kuadrant-ingressgateway
namespace: gateway-system
namespace: default
hostnames:
- api.toystore.com
rules:
Expand All @@ -53,8 +75,8 @@ EOF
Export the gateway hostname and port for testing:

```sh
export INGRESS_HOST=$(kubectl get gtw kuadrant-ingressgateway -n gateway-system -o jsonpath='{.status.addresses[0].value}')
export INGRESS_PORT=$(kubectl get gtw kuadrant-ingressgateway -n gateway-system -o jsonpath='{.spec.listeners[?(@.name=="http")].port}')
export INGRESS_HOST=$(kubectl get gtw kuadrant-ingressgateway -n default -o jsonpath='{.status.addresses[0].value}')
export INGRESS_PORT=$(kubectl get gtw kuadrant-ingressgateway -n default -o jsonpath='{.spec.listeners[?(@.name=="http")].port}')
export GATEWAY_URL=$INGRESS_HOST:$INGRESS_PORT
```

Expand Down Expand Up @@ -154,5 +176,5 @@ kubectl delete -f https://raw.githubusercontent.com/Kuadrant/kuadrant-operator/r
kubectl delete httproute toystore
kubectl delete authpolicy route-auth
kubectl delete authpolicy rule-2-auth
kubectl delete kuadrant kuadrant -n kuadrant-system
kubectl delete gateway kuadrant-ingressgateway
```

0 comments on commit 983490d

Please sign in to comment.