|
| 1 | +# Sample apps: Kong Podman |
| 2 | + |
| 3 | + |
| 4 | +## Deploy Postgres |
| 5 | + |
| 6 | +``` |
| 7 | +$ podman play kube --network=sampleapps postgres-pod.yaml |
| 8 | +``` |
| 9 | + |
| 10 | +Bootstrap Kong database for the first time: |
| 11 | +``` |
| 12 | +$ podman run --rm --pod postgres-pod --volume="./kong.conf:/etc/kong/kong.conf:ro,z" -e "KONG_PG_HOST=localhost" docker.io/library/kong:2.3.0 kong migrations bootstrap |
| 13 | +``` |
| 14 | + |
| 15 | +Test to make sure postgres works (use password `abcde12345`): |
| 16 | +``` |
| 17 | +$ podman run -it --rm --network=sampleapps docker.io/postgres:13.1-alpine psql --host=postgres-pod.sampleapps --username=kong --dbname=kongdb |
| 18 | +``` |
| 19 | + |
| 20 | + |
| 21 | +## Deploy Kong |
| 22 | + |
| 23 | +Start Kong: |
| 24 | +``` |
| 25 | +$ podman play kube --network=sampleapps kong-pod.yaml |
| 26 | +``` |
| 27 | + |
| 28 | +Test Kong and make sure no error, for example: |
| 29 | +``` |
| 30 | +$ podman run -it --rm --network=sampleapps docker.io/curlimages/curl curl http://kong-pod.sampleapps:8001 |
| 31 | +``` |
| 32 | + |
| 33 | + |
| 34 | +## Running NodeJS webservice |
| 35 | + |
| 36 | +``` |
| 37 | +$ podman build -t extra2000/webservice:latest . |
| 38 | +$ podman play kube --network=sampleapps webservice-pod.yaml |
| 39 | +``` |
| 40 | + |
| 41 | +Test make sure the NodeJS webservice is working and accessible by `kong`: |
| 42 | +``` |
| 43 | +$ podman run -it --rm --pod=webservice-pod docker.io/curlimages/curl curl http://localhost:8000/api/v1/customers |
| 44 | +$ podman run -it --rm --pod=kong-pod docker.io/curlimages/curl curl http://webservice-pod.sampleapps:8000/api/v1/customers |
| 45 | +``` |
| 46 | + |
| 47 | +Register NodeJS webservice into Kong and setup routing: |
| 48 | +``` |
| 49 | +$ podman run -it --rm --pod=kong-pod docker.io/curlimages/curl curl -i -X POST --url http://localhost:8001/services/ --data 'name=webservice' --data 'url=http://webservice-pod.sampleapps:8000' |
| 50 | +$ podman run -it --rm --pod=kong-pod docker.io/curlimages/curl curl -i -X POST --url http://localhost:8001/services/webservice/routes --data 'name=webservice-route' --data 'paths[]=/myweb' |
| 51 | +``` |
| 52 | + |
| 53 | +To test: |
| 54 | +``` |
| 55 | +$ podman run -it --rm --network=sampleapps docker.io/curlimages/curl curl -i -X GET http://kong-pod.sampleapps:8000/myweb/api/v1/customers |
| 56 | +$ curl -i -X GET http://localhost:8000/myweb/api/v1/customers |
| 57 | +``` |
| 58 | + |
| 59 | +To list services and routes: |
| 60 | +``` |
| 61 | +$ podman run -it --rm --pod=kong-pod docker.io/curlimages/curl curl -i http://localhost:8001/services |
| 62 | +$ podman run -it --rm --pod=kong-pod docker.io/curlimages/curl curl -i http://localhost:8001/routes |
| 63 | +``` |
| 64 | + |
| 65 | +To delete a service, delete their routes first: |
| 66 | +``` |
| 67 | +$ podman run -it --rm --pod=kong-pod docker.io/curlimages/curl curl -i -X DELETE --url http://localhost:8001/routes/webservice-route |
| 68 | +$ podman run -it --rm --pod=kong-pod docker.io/curlimages/curl curl -i -X DELETE --url http://localhost:8001/services/webservice |
| 69 | +``` |
| 70 | + |
| 71 | + |
| 72 | +## Cleaning up |
| 73 | + |
| 74 | +To remove all pods including containers: |
| 75 | +``` |
| 76 | +$ podman pod rm --force webservice-pod kong-pod postgres-pod |
| 77 | +``` |
0 commit comments