Skip to content

Commit a0f2a9e

Browse files
authored
Fixes for OTEL, updated README to use instead of tunnels APISIX (#820)
* Fixes for OTEL, updated README to use instead of tunnels APISIX * README update
1 parent c85978f commit a0f2a9e

8 files changed

+238
-77
lines changed

cloudbank-v32/README.md

Lines changed: 55 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,28 @@ deploy --service-name testrunner --artifact-path testrunner/target/testrunner-0.
162162
deploy --service-name transfer --artifact-path transfer/target/transfer-0.0.1-SNAPSHOT.jar --image-version 0.0.1
163163
```
164164
165+
## Create APISIX Routes
166+
167+
1. Get APISIX Gateway Admin Key
168+
169+
```shell
170+
kubectl -n apisix get configmap apisix -o yaml
171+
```
172+
173+
1. Create tunnel to APISIX
174+
175+
```shell
176+
kubectl port-forward -n apisix svc/apisix-admin 9180
177+
```
178+
179+
1. Create routes
180+
181+
In the CloudBank directory run the following command. *NOTE*, you must add the API-KEY to the command
182+
183+
````shell
184+
cd apisix-routes; source ./create-all-routes.sh <YOUR-API-KEY>; cd ..
185+
```
186+
165187
## Optional - autoscaling
166188
167189
Create autoscalers for CloudBank.
@@ -192,18 +214,25 @@ This is an example of the `customer32` application:
192214
193215
## Test CloudBank Services
194216
195-
1. Test `account` service
196-
197-
1. Port forward
217+
1. Get the external IP address
218+
219+
```shell
220+
kubectl -n ingress-nginx get service ingress-nginx-controller
221+
```
222+
223+
Result. Make a note of the EXTERNAL-IP it will be used in the tests.
224+
2.
225+
```text
226+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
227+
ingress-nginx-controller LoadBalancer 10.96.172.148 146.235.207.230 80:31393/TCP,443:30506/TCP 158m
228+
```
198229
199-
```shell
200-
kubectl port-forward -n application svc/account 8081:8080
201-
```
230+
1. Test `account` service
202231
203232
1. Rest endpoint
204233
205234
```shell
206-
curl -s http://localhost:8081/api/v1/accounts | jq
235+
curl -s http://<EXTERNAL-IP>/api/v1/accounts | jq
207236
```
208237
209238
Should return:
@@ -213,7 +242,7 @@ This is an example of the `customer32` application:
213242
{
214243
"accountBalance": -20,
215244
"accountCustomerId": "qwertysdwr",
216-
"accountId": 149,
245+
"accountId": 1,
217246
"accountName": "Andy's checking",
218247
"accountOpenedDate": "2023-06-26T17:39:37.000+00:00",
219248
"accountOtherDetails": "Account Info",
@@ -225,16 +254,10 @@ This is an example of the `customer32` application:
225254
226255
1. Test `customer` service
227256
228-
1. Port forward
229-
230-
```shell
231-
kubectl port-forward -n application svc/customer 8082:8080
232-
```
233-
234257
1. REST endpoint
235258
236259
```shell
237-
curl -s http://localhost:8082/api/v1/customer | jq
260+
curl -s http://<EXTERNAL-IP>/api/v1/customer | jq
238261
```
239262
240263
Should return:
@@ -255,16 +278,10 @@ This is an example of the `customer32` application:
255278
256279
1. Test `customer32` service
257280
258-
1. Port forward
259-
260-
```shell
261-
kubectl port-forward -n application svc/customer32 9000:8080
262-
```
263-
264281
1. REST endpoint
265282
266283
```shell
267-
curl -s http://localhost:9000/api/v2/customer | jq
284+
curl -s http://<EXTERNAL-IP>/api/v2/customer | jq
268285
```
269286
270287
Should return:
@@ -282,16 +299,10 @@ This is an example of the `customer32` application:
282299
283300
1. Test `creditscore` service
284301
285-
1. Port forward
286-
287-
```shell
288-
kubectl port-forward -n application svc/creditscore 8083:8080
289-
``````
290-
291302
1. REST endpoint
292303
293304
```shell
294-
curl -s http://localhost:8083/api/v1/creditscore | jq
305+
curl -s http://<EXTERNAL-IP>/api/v1/creditscore | jq
295306
```
296307
297308
Should return:
@@ -305,16 +316,10 @@ This is an example of the `customer32` application:
305316
306317
1. Test `check` service
307318
308-
1. Port forward
309-
310-
```shell
311-
kubectl -n application port-forward svc/testrunner 8084:8080
312-
```
313-
314-
1. REST endpoint - deposit check. Make sure you use an existing account number
319+
1. REST endpoint - deposit check. *NOTE*: Make sure you use an existing account number
315320
316321
```shell
317-
curl -i -X POST -H 'Content-Type: application/json' -d '{"accountId": 21, "amount": 256}' http://localhost:8084/api/v1/testrunner/deposit
322+
curl -i -X POST -H 'Content-Type: application/json' -d '{"accountId": 1, "amount": 256}' http://<EXTERNAL-IP>/api/v1/testrunner/deposit
318323
```
319324
320325
Should return:
@@ -340,10 +345,10 @@ This is an example of the `customer32` application:
340345
Received deposit <CheckDeposit(accountId=21, amount=256)>
341346
```
342347
343-
1. Check journal entries. Replace '21' with the account number you used.
348+
1. Check journal entries. Replace '1' with the account number you used.
344349
345350
```shell
346-
curl -i http://localhost:8081/api/v1/account/21/journal
351+
curl -i http://<EXTERNAL-ID>/api/v1/account/1/journal
347352
```
348353
349354
output should be similar to:
@@ -360,7 +365,7 @@ This is an example of the `customer32` application:
360365
1. Clearance of check - Note the JournalID from earlier step
361366
362367
```shell
363-
curl -i -X POST -H 'Content-Type: application/json' -d '{"journalId": 7}' http://localhost:8084/api/v1/testrunner/clear
368+
curl -i -X POST -H 'Content-Type: application/json' -d '{"journalId": 7}' http://<EXTERNAL-ID>/api/v1/testrunner/clear
364369
```
365370
366371
output should be similar to:
@@ -391,7 +396,7 @@ This is an example of the `customer32` application:
391396
1. Check journal -- DEPOSIT
392397
393398
```shell
394-
curl -i http://localhost:8081/api/v1/account/21/journal
399+
curl -i http://<EXTERNAL-IP>/api/v1/account/21/journal
395400
```
396401
397402
Output should look like this -- DEPOSIT
@@ -407,23 +412,17 @@ This is an example of the `customer32` application:
407412
408413
1. Run LRA Test Cases
409414
410-
1. Port forward
415+
1. Check account balances. Note that the account numbers 1 and 2 can be different in your environment
411416
412417
```shell
413-
kubectl -n application port-forward svc/transfer 8085:8080
418+
curl -s http://<EXTERNAL-IP>/api/v1/account/1 | jq ; curl -s http://<EXTERNAL-IP>/api/v1/account/2 | jq
414419
```
415420
416-
1. Check account balances. Note that the account numbers 21 and 22 can be different in your environment
417-
418-
```shell
419-
curl -s http://localhost:8081/api/v1/account/21 | jq ; curl -s http://localhost:8081/api/v1/account/22 | jq
420-
```
421-
422-
Output should be similar to this:
421+
Output should be similar to this, make a note of the account balance:
423422
424423
```json
425424
{
426-
"accountId": 21,
425+
"accountId": 1,
427426
"accountName": "Andy's checking",
428427
"accountType": "CH",
429428
"accountCustomerId": "qwertysdwr",
@@ -432,7 +431,7 @@ This is an example of the `customer32` application:
432431
"accountBalance": -20
433432
},
434433
{
435-
"accountId": 22,
434+
"accountId": 2,
436435
"accountName": "Mark's CCard",
437436
"accountType": "CC",
438437
"accountCustomerId": "bkzLp8cozi",
@@ -445,7 +444,7 @@ This is an example of the `customer32` application:
445444
1. Perform transfer between two accounts. Note account numbers
446445
447446
```shell
448-
curl -X POST "http://localhost:8085/transfer?fromAccount=22&toAccount=21&amount=100"
447+
curl -X POST "http://<EXTERNAL-IP>/transfer?fromAccount=22&toAccount=21&amount=100"
449448
```
450449
451450
Output should look like this:
@@ -457,14 +456,14 @@ This is an example of the `customer32` application:
457456
1. Check accounts to see that the transfer have occurred
458457
459458
```shell
460-
curl -s http://localhost:8081/api/v1/account/21 | jq ; curl -s http://localhost:8081/api/v1/account/22 | jq
459+
curl -s http://<EXTERNAL-IP>/api/v1/account/1 | jq ; curl -s http://<EXTERNAL-IP>/api/v1/account/2 | jq
461460
```
462461
463462
Output should be similar to this:
464463
465464
```json
466465
{
467-
"accountId": 21,
466+
"accountId": 1,
468467
"accountName": "Andy's checking",
469468
"accountType": "CH",
470469
"accountCustomerId": "qwertysdwr",
@@ -473,7 +472,7 @@ This is an example of the `customer32` application:
473472
"accountBalance": 80
474473
},
475474
{
476-
"accountId": 22,
475+
"accountId": 2,
477476
"accountName": "Mark's CCard",
478477
"accountType": "CC",
479478
"accountCustomerId": "bkzLp8cozi",

cloudbank-v32/apisix-routes/create-accounts-route.sh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ if [ $# -eq 0 ]; then
77
exit 1
88
fi
99

10-
curl http://localhost:9180/apisix/admin/routes \
10+
curl http://localhost:9180/apisix/admin/routes/1000 \
1111
-H "X-API-KEY: $1" \
12-
-X POST \
12+
-X PUT \
1313
-i \
1414
--data-binary @- << EOF
1515
{
@@ -18,17 +18,24 @@ curl http://localhost:9180/apisix/admin/routes \
1818
"version": "1.0"
1919
},
2020
"uri": "/api/v1/account*",
21+
"methods": [
22+
"GET",
23+
"POST",
24+
"PUT",
25+
"DELETE",
26+
"OPTIONS",
27+
"HEAD"
28+
],
2129
"upstream": {
2230
"service_name": "ACCOUNT",
2331
"type": "roundrobin",
2432
"discovery_type": "eureka"
2533
},
2634
"plugins": {
27-
"zipkin": {
28-
"disable": false,
29-
"endpoint": "http://jaegertracing-collector.observability.svc.cluster.local:9411/api/v2/spans",
30-
"sample_ratio": 1,
31-
"service_name": "APISIX"
35+
"opentelemetry": {
36+
"sampler": {
37+
"name": "always_on"
38+
}
3239
}
3340
}
3441
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
# Copyright (c) 2024, Oracle and/or its affiliates.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
4+
5+
if [ $# -eq 0 ]; then
6+
echo "You must supply the API key as an argument"
7+
exit 1
8+
fi
9+
10+
source ./create-accounts-route.sh $1
11+
source ./create-creditscore-route.sh $1
12+
source ./create-customer-route.sh $1
13+
source ./create-customer32-route.sh $1
14+
source ./create-testrunner-route.sh $1
15+
source ./create-transfer-route.sh $1

cloudbank-v32/apisix-routes/create-creditscore-route.sh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ if [ $# -eq 0 ]; then
77
exit 1
88
fi
99

10-
curl http://localhost:9180/apisix/admin/routes \
10+
curl http://localhost:9180/apisix/admin/routes/1001 \
1111
-H "X-API-KEY: $1" \
12-
-X POST \
12+
-X PUT \
1313
-i \
1414
--data-binary @- << EOF
1515
{
@@ -18,17 +18,24 @@ curl http://localhost:9180/apisix/admin/routes \
1818
"version": "1.0"
1919
},
2020
"uri": "/api/v1/creditscore*",
21+
"methods": [
22+
"GET",
23+
"POST",
24+
"PUT",
25+
"DELETE",
26+
"OPTIONS",
27+
"HEAD"
28+
],
2129
"upstream": {
2230
"service_name": "CREDITSCORE",
2331
"type": "roundrobin",
2432
"discovery_type": "eureka"
2533
},
2634
"plugins": {
27-
"zipkin": {
28-
"disable": false,
29-
"endpoint": "http://jaegertracing-collector.observability.svc.cluster.local:9411/api/v2/spans",
30-
"sample_ratio": 1,
31-
"service_name": "APISIX"
35+
"opentelemetry": {
36+
"sampler": {
37+
"name": "always_on"
38+
}
3239
}
3340
}
3441
}

cloudbank-v32/apisix-routes/create-customer-route.sh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ if [ $# -eq 0 ]; then
77
exit 1
88
fi
99

10-
curl http://localhost:9180/apisix/admin/routes \
10+
curl http://localhost:9180/apisix/admin/routes/1003 \
1111
-H "X-API-KEY: $1" \
12-
-X POST \
12+
-X PUT \
1313
-i \
1414
--data-binary @- << EOF
1515
{
@@ -18,17 +18,24 @@ curl http://localhost:9180/apisix/admin/routes \
1818
"version": "1.0"
1919
},
2020
"uri": "/api/v1/customer*",
21+
"methods": [
22+
"GET",
23+
"POST",
24+
"PUT",
25+
"DELETE",
26+
"OPTIONS",
27+
"HEAD"
28+
],
2129
"upstream": {
2230
"service_name": "CUSTOMER",
2331
"type": "roundrobin",
2432
"discovery_type": "eureka"
2533
},
2634
"plugins": {
27-
"zipkin": {
28-
"disable": false,
29-
"endpoint": "http://jaegertracing-collector.observability.svc.cluster.local:9411/api/v2/spans",
30-
"sample_ratio": 1,
31-
"service_name": "APISIX"
35+
"opentelemetry": {
36+
"sampler": {
37+
"name": "always_on"
38+
}
3239
}
3340
}
3441
}

0 commit comments

Comments
 (0)