Skip to content

Commit ad4678b

Browse files
Doc updates using loadbalancer with sail
1 parent e2456db commit ad4678b

8 files changed

Lines changed: 66 additions & 40 deletions

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ local-deploy: ## Deploy Kuadrant Operator in the cluster pointed by KUBECONFIG
284284
kubectl -n $(KUADRANT_NAMESPACE) wait --timeout=300s --for=condition=Available deployments --all
285285
@echo
286286
@echo "Now you can export the kuadrant gateway by doing:"
287-
@echo "kubectl port-forward -n istio-system service/istio-ingressgateway 9080:80 &"
287+
@echo "kubectl port-forward -n istio-system service/istio-ingressgateway-istio 9080:80 &"
288288
@echo "after that, you can curl -H \"Host: myhost.com\" localhost:9080"
289289
@echo "-- Linux only -- Ingress gateway is exported using nodePort service in port 9080"
290290
@echo "curl -H \"Host: myhost.com\" localhost:9080"

doc/user-guides/auth-for-app-devs-and-platform-engineers.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,28 @@ spec:
110110
EOF
111111
```
112112

113+
Export the gateway hostname and port:
114+
115+
```sh
116+
export INGRESS_HOST=$(kubectl get gtw istio-ingressgateway -n istio-system -o jsonpath='{.status.addresses[0].value}')
117+
export INGRESS_PORT=$(kubectl get gtw istio-ingressgateway -n istio-system -o jsonpath='{.spec.listeners[?(@.name=="http")].port}')
118+
export GATEWAY_URL=$INGRESS_HOST:$INGRESS_PORT
119+
```
120+
113121
Send requests to the application unprotected:
114122

115123
```sh
116-
curl -H 'Host: api.toystore.com' http://localhost:9080/cars -i
124+
curl -H 'Host: api.toystore.com' http://$GATEWAY_URL/cars -i
117125
# HTTP/1.1 200 OK
118126
```
119127

120128
```sh
121-
curl -H 'Host: api.toystore.com' http://localhost:9080/dolls -i
129+
curl -H 'Host: api.toystore.com' http://$GATEWAY_URL/dolls -i
122130
# HTTP/1.1 200 OK
123131
```
124132

125133
```sh
126-
curl -H 'Host: api.toystore.com' http://localhost:9080/admin -i
134+
curl -H 'Host: api.toystore.com' http://$GATEWAY_URL/admin -i
127135
# HTTP/1.1 200 OK
128136
```
129137

@@ -199,22 +207,22 @@ EOF
199207
Send requests to the application protected by Kuadrant:
200208

201209
```sh
202-
curl -H 'Host: api.toystore.com' http://localhost:9080/cars -i
210+
curl -H 'Host: api.toystore.com' http://$GATEWAY_URL/cars -i
203211
# HTTP/1.1 401 Unauthorized
204212
```
205213

206214
```sh
207-
curl -H 'Host: api.toystore.com' -H 'Authorization: APIKEY iamaregularuser' http://localhost:9080/cars -i
215+
curl -H 'Host: api.toystore.com' -H 'Authorization: APIKEY iamaregularuser' http://$GATEWAY_URL/cars -i
208216
# HTTP/1.1 200 OK
209217
```
210218

211219
```sh
212-
curl -H 'Host: api.toystore.com' -H 'Authorization: APIKEY iamaregularuser' http://localhost:9080/admin -i
220+
curl -H 'Host: api.toystore.com' -H 'Authorization: APIKEY iamaregularuser' http://$GATEWAY_URL/admin -i
213221
# HTTP/1.1 403 Forbidden
214222
```
215223

216224
```sh
217-
curl -H 'Host: api.toystore.com' -H 'Authorization: APIKEY iamanadmin' http://localhost:9080/admin -i
225+
curl -H 'Host: api.toystore.com' -H 'Authorization: APIKEY iamanadmin' http://$GATEWAY_URL/admin -i
218226
# HTTP/1.1 200 OK
219227
```
220228

@@ -274,7 +282,7 @@ EOF
274282
Send requests to the route protected by the default policy set at the level of the gateway:
275283

276284
```sh
277-
curl -H 'Host: foo.other-apps.com' http://localhost:9080/ -i
285+
curl -H 'Host: foo.other-apps.com' http://$GATEWAY_URL/ -i
278286
# HTTP/1.1 403 Forbidden
279287
```
280288

doc/user-guides/authenticated-rl-for-app-developers.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,27 @@ spec:
8686
EOF
8787
```
8888

89+
Export the gateway hostname and port:
90+
91+
```sh
92+
export INGRESS_HOST=$(kubectl get gtw istio-ingressgateway -n istio-system -o jsonpath='{.status.addresses[0].value}')
93+
export INGRESS_PORT=$(kubectl get gtw istio-ingressgateway -n istio-system -o jsonpath='{.spec.listeners[?(@.name=="http")].port}')
94+
export GATEWAY_URL=$INGRESS_HOST:$INGRESS_PORT
95+
```
96+
8997
Verify the route works:
9098

9199
```sh
92-
curl -H 'Host: api.toystore.com' http://localhost:9080/toy -i
100+
curl -H 'Host: api.toystore.com' http://$GATEWAY_URL/toy -i
93101
# HTTP/1.1 200 OK
94102
```
95103

96-
> **Note**: If the command above fails to hit the Toy Store API on your environment, try forwarding requests to the service:
104+
> **Note**: If the command above fails to hit the Toy Store API on your environment, try forwarding requests to the service and accessing over localhost:
97105
>
98106
> ```sh
99107
> kubectl port-forward -n istio-system service/istio-ingressgateway 9080:80 2>&1 >/dev/null &
108+
> curl -H 'Host: api.toystore.com' http://localhost:9080/toy -i
109+
> # HTTP/1.1 200 OK
100110
> ```
101111
102112
### ③ Enforce authentication on requests to the Toy Store API
@@ -139,7 +149,7 @@ EOF
139149
Verify the authentication works by sending a request to the Toy Store API without API key:
140150

141151
```sh
142-
curl -H 'Host: api.toystore.com' http://localhost:9080/toy -i
152+
curl -H 'Host: api.toystore.com' http://$GATEWAY_URL/toy -i
143153
# HTTP/1.1 401 Unauthorized
144154
# www-authenticate: APIKEY realm="api-key-users"
145155
# x-ext-auth-reason: "credential not found"
@@ -225,13 +235,13 @@ Verify the rate limiting works by sending requests as Alice and Bob.
225235
Up to 5 successful (`200 OK`) requests every 10 seconds allowed for Alice, then `429 Too Many Requests`:
226236

227237
```sh
228-
while :; do curl --write-out '%{http_code}\n' --silent --output /dev/null -H 'Authorization: APIKEY IAMALICE' -H 'Host: api.toystore.com' http://localhost:9080/toy | egrep --color "\b(429)\b|$"; sleep 1; done
238+
while :; do curl --write-out '%{http_code}\n' --silent --output /dev/null -H 'Authorization: APIKEY IAMALICE' -H 'Host: api.toystore.com' http://$GATEWAY_URL/toy | grep -E --color "\b(429)\b|$"; sleep 1; done
229239
```
230240

231241
Up to 2 successful (`200 OK`) requests every 10 seconds allowed for Bob, then `429 Too Many Requests`:
232242

233243
```sh
234-
while :; do curl --write-out '%{http_code}\n' --silent --output /dev/null -H 'Authorization: APIKEY IAMBOB' -H 'Host: api.toystore.com' http://localhost:9080/toy | egrep --color "\b(429)\b|$"; sleep 1; done
244+
while :; do curl --write-out '%{http_code}\n' --silent --output /dev/null -H 'Authorization: APIKEY IAMBOB' -H 'Host: api.toystore.com' http://$GATEWAY_URL/toy | grep -E --color "\b(429)\b|$"; sleep 1; done
235245
```
236246

237247
## Cleanup

doc/user-guides/authenticated-rl-with-jwt-and-k8s-authnz.md

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,27 @@ kubectl apply -f examples/toystore/httproute.yaml
8282

8383
#### Try the API unprotected
8484

85+
Export the gateway hostname and port:
86+
87+
```sh
88+
export INGRESS_HOST=$(kubectl get gtw istio-ingressgateway -n istio-system -o jsonpath='{.status.addresses[0].value}')
89+
export INGRESS_PORT=$(kubectl get gtw istio-ingressgateway -n istio-system -o jsonpath='{.spec.listeners[?(@.name=="http")].port}')
90+
export GATEWAY_URL=$INGRESS_HOST:$INGRESS_PORT
91+
```
92+
8593
```sh
86-
curl -H 'Host: api.toystore.com' http://localhost:9080/toy -i
94+
curl -H 'Host: api.toystore.com' http://$GATEWAY_URL/toy -i
8795
# HTTP/1.1 200 OK
8896
```
8997

9098
It should return `200 OK`.
9199

92-
> **Note**: If the command above fails to hit the Toy Store API on your environment, try forwarding requests to the service:
100+
> **Note**: If the command above fails to hit the Toy Store API on your environment, try forwarding requests to the service and accessing over localhost:
93101
>
94102
> ```sh
95103
> kubectl port-forward -n istio-system service/istio-ingressgateway 9080:80 2>&1 >/dev/null &
104+
> curl -H 'Host: api.toystore.com' http://localhost:9080/toy -i
105+
> # HTTP/1.1 200 OK
96106
> ```
97107
98108
### ③ Deploy Keycloak
@@ -157,7 +167,7 @@ EOF
157167
#### Try the API missing authentication
158168

159169
```sh
160-
curl -H 'Host: api.toystore.com' http://localhost:9080/toy -i
170+
curl -H 'Host: api.toystore.com' http://$GATEWAY_URL/toy -i
161171
# HTTP/1.1 401 Unauthorized
162172
# www-authenticate: Bearer realm="keycloak-users"
163173
# www-authenticate: Bearer realm="k8s-service-accounts"
@@ -175,7 +185,7 @@ ACCESS_TOKEN=$(kubectl run token --attach --rm --restart=Never -q --image=curlim
175185
Send a request to the API as the Keycloak-authenticated user while still missing permissions:
176186

177187
```sh
178-
curl -H "Authorization: Bearer $ACCESS_TOKEN" -H 'Host: api.toystore.com' http://localhost:9080/toy -i
188+
curl -H "Authorization: Bearer $ACCESS_TOKEN" -H 'Host: api.toystore.com' http://$GATEWAY_URL/toy -i
179189
# HTTP/1.1 403 Forbidden
180190
```
181191

@@ -199,7 +209,7 @@ SA_TOKEN=$(kubectl create token client-app-1)
199209
Send a request to the API as the service account while still missing permissions:
200210

201211
```sh
202-
curl -H "Authorization: Bearer $SA_TOKEN" -H 'Host: api.toystore.com' http://localhost:9080/toy -i
212+
curl -H "Authorization: Bearer $SA_TOKEN" -H 'Host: api.toystore.com' http://$GATEWAY_URL/toy -i
203213
# HTTP/1.1 403 Forbidden
204214
```
205215

@@ -281,24 +291,24 @@ EOF
281291
Send requests to the API as the Keycloak-authenticated user:
282292

283293
```sh
284-
curl -H "Authorization: Bearer $ACCESS_TOKEN" -H 'Host: api.toystore.com' http://localhost:9080/toy -i
294+
curl -H "Authorization: Bearer $ACCESS_TOKEN" -H 'Host: api.toystore.com' http://$GATEWAY_URL/toy -i
285295
# HTTP/1.1 200 OK
286296
```
287297

288298
```sh
289-
curl -H "Authorization: Bearer $ACCESS_TOKEN" -H 'Host: api.toystore.com' -X POST http://localhost:9080/admin/toy -i
299+
curl -H "Authorization: Bearer $ACCESS_TOKEN" -H 'Host: api.toystore.com' -X POST http://$GATEWAY_URL/admin/toy -i
290300
# HTTP/1.1 200 OK
291301
```
292302

293303
Send requests to the API as the Kubernetes service account:
294304

295305
```sh
296-
curl -H "Authorization: Bearer $SA_TOKEN" -H 'Host: api.toystore.com' http://localhost:9080/toy -i
306+
curl -H "Authorization: Bearer $SA_TOKEN" -H 'Host: api.toystore.com' http://$GATEWAY_URL/toy -i
297307
# HTTP/1.1 200 OK
298308
```
299309

300310
```sh
301-
curl -H "Authorization: Bearer $SA_TOKEN" -H 'Host: api.toystore.com' -X POST http://localhost:9080/admin/toy -i
311+
curl -H "Authorization: Bearer $SA_TOKEN" -H 'Host: api.toystore.com' -X POST http://$GATEWAY_URL/admin/toy -i
302312
# HTTP/1.1 403 Forbidden
303313
```
304314

@@ -339,13 +349,13 @@ Each user should be entitled to a maximum of 5 requests every 10 seconds.
339349
Send requests as the Keycloak-authenticated user:
340350

341351
```sh
342-
while :; do curl --write-out '%{http_code}\n' --silent --output /dev/null -H "Authorization: Bearer $ACCESS_TOKEN" -H 'Host: api.toystore.com' http://localhost:9080/toy | egrep --color "\b(429)\b|$"; sleep 1; done
352+
while :; do curl --write-out '%{http_code}\n' --silent --output /dev/null -H "Authorization: Bearer $ACCESS_TOKEN" -H 'Host: api.toystore.com' http://$GATEWAY_URL/toy | grep -E --color "\b(429)\b|$"; sleep 1; done
343353
```
344354

345355
Send requests as the Kubernetes service account:
346356

347357
```sh
348-
while :; do curl --write-out '%{http_code}\n' --silent --output /dev/null -H "Authorization: Bearer $SA_TOKEN" -H 'Host: api.toystore.com' http://localhost:9080/toy | egrep --color "\b(429)\b|$"; sleep 1; done
358+
while :; do curl --write-out '%{http_code}\n' --silent --output /dev/null -H "Authorization: Bearer $SA_TOKEN" -H 'Host: api.toystore.com' http://$GATEWAY_URL/toy | grep -E --color "\b(429)\b|$"; sleep 1; done
349359
```
350360

351361
## Cleanup

doc/user-guides/gateway-dns.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ Deploy policy controller and install DNSPolicy CRD:
3131
make deploy-policy-controller
3232
```
3333

34-
Install metallb:
35-
```shell
36-
make install-metallb
37-
```
38-
3934
Create a namespace:
4035
```shell
4136
kubectl create namespace my-gateways

doc/user-guides/gateway-rl-for-cluster-operators.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,13 @@ kubectl port-forward -n istio-system service/internal-istio 9082:80 2>&1 >/dev/n
188188
Up to 5 successful (`200 OK`) requests every 10 seconds through the `external` ingress gateway (`*.io`), then `429 Too Many Requests`:
189189

190190
```sh
191-
while :; do curl --write-out '%{http_code}\n' --silent --output /dev/null -H 'Host: api.toystore.io' http://localhost:9081 | egrep --color "\b(429)\b|$"; sleep 1; done
191+
while :; do curl --write-out '%{http_code}\n' --silent --output /dev/null -H 'Host: api.toystore.io' http://localhost:9081 | grep -E --color "\b(429)\b|$"; sleep 1; done
192192
```
193193

194194
Unlimited successful (`200 OK`) through the `internal` ingress gateway (`*.local`):
195195

196196
```sh
197-
while :; do curl --write-out '%{http_code}\n' --silent --output /dev/null -H 'Host: api.toystore.local' http://localhost:9082 | egrep --color "\b(429)\b|$"; sleep 1; done
197+
while :; do curl --write-out '%{http_code}\n' --silent --output /dev/null -H 'Host: api.toystore.local' http://localhost:9082 | grep -E --color "\b(429)\b|$"; sleep 1; done
198198
```
199199

200200
## Cleanup

doc/user-guides/gateway-tls.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ Deploy policy controller and install TLSPolicy CRD:
3030
make deploy-policy-controller
3131
```
3232

33-
Install metallb:
34-
```shell
35-
make install-metallb
36-
```
37-
3833
Create a namespace:
3934
```shell
4035
kubectl create namespace my-gateways

doc/user-guides/simple-rl-for-app-developers.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,18 @@ spec:
8787
EOF
8888
```
8989

90+
Export the gateway hostname and port:
91+
92+
```sh
93+
export INGRESS_HOST=$(kubectl get gtw istio-ingressgateway -n istio-system -o jsonpath='{.status.addresses[0].value}')
94+
export INGRESS_PORT=$(kubectl get gtw istio-ingressgateway -n istio-system -o jsonpath='{.spec.listeners[?(@.name=="http")].port}')
95+
export GATEWAY_URL=$INGRESS_HOST:$INGRESS_PORT
96+
```
97+
9098
Verify the route works:
9199

92100
```sh
93-
curl -H 'Host: api.toystore.com' http://localhost:9080/toys -i
101+
curl -H 'Host: api.toystore.com' http://$GATEWAY_URL/toys -i
94102
# HTTP/1.1 200 OK
95103
```
96104

@@ -141,13 +149,13 @@ Verify the rate limiting works by sending requests in a loop.
141149
Up to 5 successful (`200 OK`) requests every 10 seconds to `POST /toys`, then `429 Too Many Requests`:
142150

143151
```sh
144-
while :; do curl --write-out '%{http_code}\n' --silent --output /dev/null -H 'Host: api.toystore.com' http://localhost:9080/toys -X POST | egrep --color "\b(429)\b|$"; sleep 1; done
152+
while :; do curl --write-out '%{http_code}\n' --silent --output /dev/null -H 'Host: api.toystore.com' http://$GATEWAY_URL/toys -X POST | grep -E --color "\b(429)\b|$"; sleep 1; done
145153
```
146154

147155
Unlimited successful (`200 OK`) to `GET /toys`:
148156

149157
```sh
150-
while :; do curl --write-out '%{http_code}\n' --silent --output /dev/null -H 'Host: api.toystore.com' http://localhost:9080/toys | egrep --color "\b(429)\b|$"; sleep 1; done
158+
while :; do curl --write-out '%{http_code}\n' --silent --output /dev/null -H 'Host: api.toystore.com' http://$GATEWAY_URL/toys | grep -E --color "\b(429)\b|$"; sleep 1; done
151159
```
152160

153161
## Cleanup

0 commit comments

Comments
 (0)