Skip to content

Commit

Permalink
Use KONNECT_PROXY_URL on the get started guide for konnect
Browse files Browse the repository at this point in the history
Re-do the Konnect prereq and update the markdown accordingly.
  • Loading branch information
fabianrbz committed Dec 20, 2024
1 parent bafa434 commit 0d72f56
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
39 changes: 38 additions & 1 deletion app/_how-tos/get-started-with-gateway.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,25 @@ entities:

Using the Service and Route, you can now
access `https://httpbin.konghq.com/` using `http://localhost:8000/mock`.
{: data-deployment-topology="on-prem" }

Using the Service and Route, you can now
access `https://httpbin.konghq.com/` using `$KONNECT_PROXY_URL/mock`.
{: data-deployment-topology="konnect" }

Httpbin provides an `/anything` resource which will return information about requests made to it.
Proxy a request through {{site.base_gateway}} to the `/anything` resource:

```sh
curl -X GET http://localhost:8000/mock/anything
```
{: data-deployment-topology="on-prem" }

```sh
curl -X GET $KONNECT_PROXY_URL/mock/anything
```
{: data-deployment-topology="konnect" }


## 4. Enable rate limiting

Expand Down Expand Up @@ -189,8 +201,15 @@ the returned headers.
The Proxy Cache plugin returns status information headers prefixed with `X-Cache`, so you can use `grep` to filter for that information:

```sh
for _ in {1..6}; do curl -s -i localhost:8000/mock/anything; echo; sleep 1; done | grep -E 'X-Cache|HTTP/1.1'
for _ in {1..6}; do curl -s -i http://localhost:8000/mock/anything; echo; sleep 1; done | grep -E 'X-Cache|HTTP/1.1'
```
{: data-deployment-topology="on-prem" }

```sh
for _ in {1..6}; do curl -s -i $KONNECT_PROXY_URL/mock/anything; echo; sleep 1; done | grep -E 'X-Cache|HTTP/1.1'
```
{: data-deployment-topology="konnect" }


On the initial request, there should be no cached responses, and the headers will indicate this with
`X-Cache-Status: Miss`:
Expand Down Expand Up @@ -269,6 +288,12 @@ Only specify a key for testing or when migrating existing systems.
```sh
curl -i http://localhost:8000/mock/anything
```
{: data-deployment-topology="on-prem" }

```sh
curl -i $KONNECT_PROXY_URL/mock/anything
```
{: data-deployment-topology="konnect" }

Since you enabled key authentication globally, you will receive an unauthorized response:

Expand All @@ -287,6 +312,12 @@ Now, let's send a request with the valid key in the `apikey` header:
curl -i http://localhost:8000/mock/anything \
-H 'apikey:top-secret-key'
```
{: data-deployment-topology="on-prem" }

```sh
curl -i $KONNECT_PROXY_URL/mock/anything
```
{: data-deployment-topology="konnect" }

You will receive a `200 OK` response.

Expand Down Expand Up @@ -340,6 +371,12 @@ You will see the hostname change between `httpbin` and `httpbun`:
```sh
curl -s http://localhost:8000/mock/headers -H 'apikey:top-secret-key' | grep -i -A1 '"host"'
```
{: data-deployment-topology="on-prem" }

```sh
curl -s $KONNECT_PROXY_URL/mock/headers -H 'apikey:top-secret-key' | grep -i -A1 '"host"'
```
{: data-deployment-topology="konnect" }

Since the Proxy Cache plugin is configured with a time-to-live of 5 seconds,
the host will take at least 5 seconds to change.
Expand Down
10 changes: 5 additions & 5 deletions app/_includes/prereqs/products/konnect.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ If you don't have a Konnect account, you can get started quickly with our [onboa

1. The following Konnect items are required to complete this tutorial:

* Personal access token (PAT): Create a new personal access token by opening the [Konnect PAT page](https://cloud.konghq.com/global/account/tokens) and selecting **Generate Token**.
* Control Plane: You can use an existing Control Plane or [create a new one](https://cloud.konghq.com/us/gateway-manager/create-control-plane) to use for this tutorial.
* Control Plane ID: You can see your Control Plane ID by selecting a Control Plane from the [Gateway Manager](https://cloud.konghq.com/us/gateway-manager/) in Konnect.
* A Data Plane node running on `localhost:8000` (default): You can set up Data Plane nodes for your Control Plane from the [Gateway Manager](https://cloud.konghq.com/us/gateway-manager/) in Konnect.
* Personal access token (PAT): Create a new personal access token by opening the [Konnect PAT page](https://cloud.konghq.com/global/account/tokens) and selecting **Generate Token**.
* Control Plane Name: You can use an existing Control Plane or [create a new one](https://cloud.konghq.com/us/gateway-manager/create-control-plane) to use for this tutorial.
* Konnect Proxy URL: By default, a self-hosted Data Plane uses `http://localhost:8000`. You can set up Data Plane nodes for your Control Plane from the [Gateway Manager](https://cloud.konghq.com/us/gateway-manager/) in Konnect.

2. Set the personal access token and the Control Plane ID as environment variables:
2. Set the personal access token, the Control Plane Name and the Konnect proxy url as environment variables:

```sh
export KONNECT_TOKEN=your-token
export KONNECT_CP_NAME=your-control-plane-name
export KONNECT_PROXY_URL=konnect-proxy-url
```

{% endcapture %}
Expand Down

0 comments on commit 0d72f56

Please sign in to comment.