Kong Gateway Certified Associate: 12 Practice Labs

Kong says its Gateway Associate training covers the theoretical and practical aspects of the exam. Kong’s bootcamp listing describes a two hour open book exam, and the Gateway Operations course is required in order to take the exam. Check the current objectives on Kong Academy before you book. Kong also now offers a separate Konnect Certified Associate, so make sure you’re studying for the right one.

Kong Gateway Certified Associate: 12 Practice Labs

If you can do every lab below without looking at the solution, you’re well prepared for the core skills. I’m assuming Docker, curl and jq. Use a current 3.x image tag (I use 3.4 below).

Ports to memorise: 8000 proxy (HTTP), 8443 proxy (HTTPS), 8001 Admin API (HTTP), 8444 Admin API (HTTPS), 8002 Kong Manager, 8005/8006 hybrid cluster and telemetry.


Lab 0: Build the environment

docker network create kong-net

docker run -d --name kong-db --network kong-net \
  -e POSTGRES_USER=kong -e POSTGRES_DB=kong -e POSTGRES_PASSWORD=kongpass postgres:13

docker run --rm --network kong-net \
  -e KONG_DATABASE=postgres -e KONG_PG_HOST=kong-db -e KONG_PG_PASSWORD=kongpass \
  kong/kong-gateway:3.4 kong migrations bootstrap

docker run -d --name kong --network kong-net \
  -e KONG_DATABASE=postgres -e KONG_PG_HOST=kong-db -e KONG_PG_PASSWORD=kongpass \
  -e KONG_PROXY_ACCESS_LOG=/dev/stdout -e KONG_ADMIN_ACCESS_LOG=/dev/stdout \
  -e KONG_PROXY_ERROR_LOG=/dev/stderr  -e KONG_ADMIN_ERROR_LOG=/dev/stderr \
  -e KONG_ADMIN_LISTEN="0.0.0.0:8001" -e KONG_ADMIN_GUI_URL=http://localhost:8002 \
  -p 8000:8000 -p 8443:8443 -p 8001:8001 -p 8444:8444 -p 8002:8002 \
  kong/kong-gateway:3.4

# Upstream test app
docker run -d --name httpbin1 --network kong-net kennethreitz/httpbin

Verify:

curl -s localhost:8001/status | jq      # database reachable, server connections
curl -s localhost:8001/ | jq '.version, .configuration.database'
docker exec kong kong health

Instructor note: The order is always migrations bootstrap (first install), then start. On upgrades, you use migrations up then migrations finish. Expect a question on what happens if you skip bootstrap (Kong refuses to start with a “database needs bootstrapping” error).


Lab 1: Service and Route, proxy a request

Task: Expose httpbin1 at http://localhost:8000/api, so that /api/get reaches the upstream as /get.

curl -i -X POST localhost:8001/services \
  --data name=httpbin-svc --data url=http://httpbin1:80

curl -i -X POST localhost:8001/services/httpbin-svc/routes \
  --data name=httpbin-route --data 'paths[]=/api' --data strip_path=true

curl -i localhost:8000/api/get
curl -s localhost:8000/api/get | jq .url

Expected: 200, plus X-Kong-Upstream-Latency and X-Kong-Proxy-Latency headers.

Experiments:

# strip_path=false: upstream now receives /api/get and returns 404
curl -X PATCH localhost:8001/routes/httpbin-route --data strip_path=false
curl -i localhost:8000/api/get

# Restore, then restrict by method and host
curl -X PATCH localhost:8001/routes/httpbin-route --data strip_path=true
curl -X PATCH localhost:8001/routes/httpbin-route --data 'methods[]=GET'
curl -i -X POST localhost:8000/api/post       # 404 no Route matched

Instructor note: Know the request flow. A request matches a Route (hosts, paths, methods, headers, snis). The Route points to a Service, which points to an upstream. A Route belongs to only one Service. A Service can have many Routes. strip_path and the Service path field are the classic trick questions.


Lab 2: Authentication with Key Auth and Consumers

Task: Protect the Service. Create consumer alice with key alice-secret.

curl -X POST localhost:8001/services/httpbin-svc/plugins --data name=key-auth

curl -i localhost:8000/api/get                          # 401 No API key found
curl -X POST localhost:8001/consumers --data username=alice
curl -X POST localhost:8001/consumers/alice/key-auth --data key=alice-secret

curl -i localhost:8000/api/get -H 'apikey: alice-secret'   # 200
curl -i localhost:8000/api/get -H 'apikey: wrong'          # 401 Invalid credentials

Variations to practice:

# Accept key from query string only, custom header name
curl -X PATCH localhost:8001/plugins/<plugin-id> \
  --data 'config.key_names[]=x-api-key' --data 'config.key_in_header=true' \
  --data 'config.hide_credentials=true'

Instructor note: Memorise these error messages. A missing key gives 401 “No API key found in request”. An invalid key gives 401 “Invalid authentication credentials”. hide_credentials stops Kong forwarding the key to the upstream.


Lab 3: Rate limiting per Consumer

Task: Allow alice 5 requests per minute. Show the 429.

curl -X POST localhost:8001/consumers/alice/plugins \
  --data name=rate-limiting --data config.minute=5 --data config.policy=local

for i in $(seq 1 7); do
  curl -s -o /dev/null -w "%{http_code}\n" localhost:8000/api/get -H 'apikey: alice-secret'
done
# 200 x5, then 429

curl -i localhost:8000/api/get -H 'apikey: alice-secret' | grep -i ratelimit

Instructor note:

  • Policies are local (per node, fast, approximate in a cluster), cluster (database, accurate but slower, not for hybrid DPs) and redis (accurate and scalable).
  • limit_by options are consumer (the default), credential, ip, service, header and path.
  • Plugin precedence is a favourite question. The most specific wins: Consumer+Route+Service, then Consumer+Route, Consumer+Service, Route+Service, Consumer, Route, Service, and Global last. Only one instance of a given plugin runs per request.

Lab 4: ACL and authorization

Task: Only consumers in group gold may call the API. bob has a valid key but no group.

curl -X POST localhost:8001/services/httpbin-svc/plugins \
  --data name=acl --data 'config.allow[]=gold'

curl -X POST localhost:8001/consumers --data username=bob
curl -X POST localhost:8001/consumers/bob/key-auth --data key=bob-secret

curl -i localhost:8000/api/get -H 'apikey: bob-secret'     # 403 You cannot consume this service
curl -X POST localhost:8001/consumers/alice/acls --data group=gold
curl -i localhost:8000/api/get -H 'apikey: alice-secret'   # 200

Instructor note: ACL needs an authentication plugin first, because it must identify the consumer. 401 means authentication failed. 403 means authentication passed but authorization failed. Examiners love this distinction. Also know allow versus deny.


Lab 5: Load balancing with Upstreams, Targets and health checks

Task: Balance across two backends, with active and passive health checks. Show a target going unhealthy.

docker run -d --name httpbin2 --network kong-net kennethreitz/httpbin

curl -X POST localhost:8001/upstreams \
  --data name=httpbin-upstream \
  --data healthchecks.active.http_path=/status/200 \
  --data healthchecks.active.healthy.interval=5 \
  --data healthchecks.active.unhealthy.interval=5 \
  --data healthchecks.active.unhealthy.http_failures=2 \
  --data healthchecks.passive.unhealthy.http_failures=2

curl -X POST localhost:8001/upstreams/httpbin-upstream/targets --data target=httpbin1:80 --data weight=100
curl -X POST localhost:8001/upstreams/httpbin-upstream/targets --data target=httpbin2:80 --data weight=100

# Point the Service at the upstream NAME
curl -X PATCH localhost:8001/services/httpbin-svc --data host=httpbin-upstream --data port=80

curl -s localhost:8001/upstreams/httpbin-upstream/health | jq
docker stop httpbin2
sleep 15
curl -s localhost:8001/upstreams/httpbin-upstream/health | jq '.data[] | {target, health}'
curl -i localhost:8000/api/get -H 'apikey: alice-secret'   # still 200

Instructor note:

  • A Service’s host must equal the Upstream name for the balancer to apply.
  • The default algorithm is round-robin. Others are consistent-hashing (set hash_on) and least-connections. Newer versions also offer latency and sticky-sessions.
  • Active checks probe on a schedule. Passive checks watch real traffic and never recover a target by themselves. Only active checks mark a target healthy again.
  • If all targets are unhealthy, you get 503 “failure to get a peer from the ring-balancer”.

Lab 6: Transform requests and responses

Task: Add a header on the way in, remove one, add a response header, and add a correlation ID.

curl -X POST localhost:8001/routes/httpbin-route/plugins \
  --data name=request-transformer \
  --data 'config.add.headers[]=x-instructor:kong' \
  --data 'config.remove.headers[]=user-agent'

curl -X POST localhost:8001/routes/httpbin-route/plugins \
  --data name=response-transformer \
  --data 'config.add.headers[]=X-Powered-By:kong-lab'

curl -X POST localhost:8001/routes/httpbin-route/plugins \
  --data name=correlation-id --data config.header_name=X-Request-ID --data config.generator=uuid

curl -si localhost:8000/api/headers -H 'apikey: alice-secret'

Expected: The JSON body shows X-Instructor and X-Request-Id as the upstream saw them. Response headers include X-Powered-By.

Instructor note: The transformer config sections are add, append, remove, rename and replace. add only sets a value if it is missing. replace only changes it if it exists.


Lab 7: Proxy caching

curl -X POST localhost:8001/routes/httpbin-route/plugins \
  --data name=proxy-cache --data config.strategy=memory \
  --data 'config.content_type[]=application/json' \
  --data config.cache_ttl=30 --data 'config.request_method[]=GET'

curl -si localhost:8000/api/get -H 'apikey: alice-secret' | grep -i x-cache
# X-Cache-Status: Miss
curl -si localhost:8000/api/get -H 'apikey: alice-secret' | grep -i x-cache
# X-Cache-Status: Hit

# Purge
curl -X DELETE localhost:8001/proxy-cache

Instructor note: Know the statuses Miss, Hit, Refresh and Bypass. The default cacheable methods are GET and HEAD. The cache key includes the consumer or credential when an auth plugin is active.


Lab 8: JWT authentication

Task: Protect a separate route with JWT, using a token you sign yourself.

curl -X POST localhost:8001/services --data name=jwt-svc --data url=http://httpbin1:80
curl -X POST localhost:8001/services/jwt-svc/routes --data name=jwt-route --data 'paths[]=/jwt'
curl -X POST localhost:8001/routes/jwt-route/plugins --data name=jwt \
  --data 'config.claims_to_verify[]=exp'

curl -X POST localhost:8001/consumers/alice/jwt \
  --data algorithm=HS256 --data key=alice-issuer --data secret=supersecret

b64() { openssl base64 -A | tr '+/' '-_' | tr -d '='; }
H=$(printf '{"alg":"HS256","typ":"JWT"}' | b64)
P=$(printf '{"iss":"alice-issuer","exp":%d}' $(( $(date +%s)+3600 )) | b64)
S=$(printf '%s.%s' "$H" "$P" | openssl dgst -sha256 -hmac supersecret -binary | b64)
TOKEN="$H.$P.$S"

curl -i localhost:8000/jwt/get -H "Authorization: Bearer $TOKEN"    # 200
curl -i localhost:8000/jwt/get                                      # 401

Instructor note: The credential’s key must match the token’s iss claim by default (configurable via key_claim_name). The credential secret is what Kong validates the signature with.


Lab 9: Declarative config, decK and DB-less mode

Part A: decK against the database

# decK >= 1.28 uses "deck gateway ..."; older versions use "deck dump/diff/sync"
deck gateway dump -o kong.yaml
deck gateway diff kong.yaml
deck gateway sync kong.yaml

Part B: DB-less node

# kong.yml
_format_version: "3.0"
services:
- name: httpbin-svc
  url: http://httpbin1:80
  routes:
  - name: httpbin-route
    paths: [/api]
  plugins:
  - name: rate-limiting
    config: {minute: 5, policy: local}
docker exec kong kong config parse /path/kong.yml     # validate syntax first

docker run -d --name kong-dbless --network kong-net \
  -e KONG_DATABASE=off -e KONG_DECLARATIVE_CONFIG=/kong/declarative/kong.yml \
  -e KONG_ADMIN_LISTEN=0.0.0.0:8001 \
  -v $(pwd)/kong.yml:/kong/declarative/kong.yml \
  -p 9000:8000 -p 9001:8001 kong/kong-gateway:3.4

curl -i -X POST localhost:9001/services --data name=x --data url=http://a   # 405: read-only
curl -X POST localhost:9001/config -F config=@kong.yml                       # hot reload

Instructor note: In DB-less mode the Admin API is read-only except /config. Some plugins that need a database (for example the cluster rate-limit policy) are unavailable. sync makes the target match the file exactly and deletes anything extra. diff is the safe dry run.


Lab 10: Workspaces and RBAC (Enterprise)

This needs an Enterprise licence or trial. Free mode only has the default workspace, so check which edition your exam environment uses.

# Start Kong with RBAC. Bootstrap with KONG_PASSWORD=<super-admin-pass>, then run Kong with:
#   -e KONG_ENFORCE_RBAC=on -e KONG_ADMIN_GUI_AUTH=basic-auth
#   -e KONG_ADMIN_GUI_SESSION_CONF='{"secret":"s3cr3t","cookie_secure":false}'

curl -X POST localhost:8001/workspaces --data name=team-a -H 'Kong-Admin-Token: <super-admin-pass>'

# Entities are scoped per workspace via the URL prefix
curl -X POST localhost:8001/team-a/services --data name=a-svc --data url=http://httpbin1:80 \
  -H 'Kong-Admin-Token: <token>'

# Role limited to team-a
curl -X POST localhost:8001/team-a/rbac/roles --data name=team-a-admin -H 'Kong-Admin-Token: <token>'
curl -X POST localhost:8001/team-a/rbac/roles/team-a-admin/endpoints \
  --data workspace=team-a --data endpoint='*' --data actions='*' -H 'Kong-Admin-Token: <token>'
curl -X POST localhost:8001/rbac/users --data name=alice-admin --data user_token=tokenA \
  -H 'Kong-Admin-Token: <token>'
curl -X POST localhost:8001/rbac/users/alice-admin/roles --data roles=team-a-admin \
  -H 'Kong-Admin-Token: <token>'

Verify the exact RBAC endpoint paths against the docs for your Kong version, because they have shifted slightly between releases.

Instructor note: The header is Kong-Admin-Token. A workspace isolates Services, Routes, Consumers and Plugins, but not the data plane nodes.


Lab 11: Logging and metrics

curl -X POST localhost:8001/routes/httpbin-route/plugins \
  --data name=file-log --data config.path=/tmp/kong-lab.log

curl -s localhost:8000/api/get -H 'apikey: alice-secret' > /dev/null
docker exec kong tail -n1 /tmp/kong-lab.log | jq '{request: .request.uri, status: .response.status, latencies}'

# Prometheus
curl -X POST localhost:8001/plugins --data name=prometheus
curl -s localhost:8001/metrics | grep kong_http_requests_total

Instructor note: Know the three latency fields: kong (time spent in Kong), proxy (time waiting on the upstream) and request (total). Other logging plugins to recognise are http-log, syslog, tcp-log, datadog and opentelemetry.


Lab 12: Troubleshooting drill

Break things deliberately and match the symptom to the cause.

SymptomLikely causeHow to check
404 {"message":"no Route matched with those values"}Wrong path, host or method, or strip_path confusioncurl localhost:8001/routes | jq
401Missing or invalid credentialCheck key_names and the credential exists
403ACL or IP restrictionCheck consumer groups and allow/deny
429Rate limit hitLook at the X-RateLimit-* headers
502Upstream sent a bad response or closed the connectionHit the upstream directly
503 “name resolution failed” or “failure to get a peer”DNS or health check failure, no healthy targets/upstreams/<n>/health
504Upstream timeoutread_timeout and connect_timeout on the Service
docker exec kong kong health
docker logs kong --tail 50
curl -s localhost:8001/services/httpbin-svc | jq
curl -s localhost:8001/plugins | jq '.data[] | {name, route: .route, service: .service, consumer: .consumer}'
docker exec kong kong reload

Break-it exercise: Set the Service port to 9999 and read the error. Set it to a bogus hostname and read the new error. Seeing both makes the 502 and 503 difference stick.


Bonus: Hybrid mode (Control Plane and Data Plane)

docker run --rm -v $(pwd):/certs kong/kong-gateway:3.4 \
  kong hybrid gen_cert /certs/cluster.crt /certs/cluster.key
  • Control Plane: KONG_ROLE=control_plane, KONG_CLUSTER_CERT, KONG_CLUSTER_CERT_KEY, KONG_CLUSTER_LISTEN=0.0.0.0:8005, KONG_CLUSTER_TELEMETRY_LISTEN=0.0.0.0:8006, with the database enabled.
  • Data Plane: KONG_ROLE=data_plane, KONG_DATABASE=off, KONG_CLUSTER_CONTROL_PLANE=<cp-host>:8005, KONG_CLUSTER_TELEMETRY_ENDPOINT=<cp-host>:8006, the same cert and key.

You configure through the CP Admin API and the DPs pull the config. If the CP goes down, DPs keep serving from their cached config.


Exam-day tips from an instructor

  1. Know the entity model cold: Service, Route, Consumer, Plugin, Upstream, Target and Certificate/SNI.
  2. Use the Admin API and docs fluently. With an open-book exam, speed at finding developer.konghq.com pages matters more than memorisation.
  3. Learn GET / and GET /status. Use them to confirm version, edition and loaded plugins.
  4. Drill plugin scopes and precedence. This is where marks get dropped.
  5. Run every lab twice, once with curl and once in Kong Manager at :8002.

Leave a Reply

Your email address will not be published. Required fields are marked *