Kong Gateway Certified Associate – Practical Lab Scenarios – Part B

Part B – Upstreams, Targets, Load Balancing and Health Checks

Exam-style hands-on labs with Kong Manager (UI) steps, Admin API / decK / CLI commands, verification and gotchas.

Honest note: the real exam questions are confidential, so nobody can give you the exact ones. These labs are modelled on the published exam objectives (services/routes, upstreams and health checks, consumers and authentication, plugins, traffic control, transformations, logging, workspaces/RBAC, decK/DB-less, hybrid mode, TLS, CLI and troubleshooting) and on the style of tasks you are expected to perform: configure it, then prove it works.


Lab environment and assumptions

ItemValue
Kong Gateway3.x (OSS or Enterprise; Enterprise-only labs are marked [EE])
Admin APIhttp://localhost:8001
Kong Managerhttp://localhost:8002
Proxyhttp://localhost:8000 (HTTPS :8443)
Upstream test apphttp://httpbin.org (or a local kong/httpbin / mccutchen/go-httpbin container)
# Handy aliases used in all labs
export ADMIN=http://localhost:8001
export PROXY=http://localhost:8000

Universal verification checklist (use this on EVERY task)

  1. Config exists: curl -s $ADMIN/services | jq , /routes, /plugins, /consumers, /upstreams/<name>/targets.
  2. Traffic test with headers visible: curl -i ... (never plain curl – status line and headers are your evidence).
  3. Read the status code:
CodeUsual Kong meaning
200/2xxRoute matched, upstream answered
400Bad request / invalid header / plugin validation
401Authentication plugin: missing or invalid credentials
403Authenticated but not authorised (ACL, ip-restriction, invalid key scope)
404 no Route matched with those valuesNo route matched (path/host/method/header) – the problem is the route
413request-size-limiting
429rate-limiting
500Plugin or Kong internal error – check error.log
502Kong reached/parsed upstream badly (connection refused, bad response)
503No healthy target / name resolution failed / service unavailable
504Upstream timed out (read/send/connect timeout)
  1. Useful response headers: X-Kong-Upstream-Latency, X-Kong-Proxy-Latency, Via: kong/x.y, X-RateLimit-Limit-Minute, X-RateLimit-Remaining-Minute, RateLimit-*, X-Cache-Status, X-Kong-Request-Id.
  2. Logs: default prefix /usr/local/kong/logs/ → error.log, access.log. In Docker: docker logs <kong>.
  3. Declarative / DB-less mode is read-only through the Admin API (POST/PUT/PATCH/DELETE return 405). Change kong.yml and reload.
  4. Scope matters: a plugin may exist but be attached to a different route/service/consumer than the one you test.

Plugin precedence (most specific wins – only ONE instance of a plugin runs per request)

Consumer + Route + Service → Consumer + Route → Consumer + Service → Route + Service → Consumer → Route → Service → Global.

Lab 13 – Round-robin load balancing across two targets

Task: Two backends echo1:8080 and echo2:8080. Load-balance them behind /lb.

UI: Upstreams → New Upstream (lb-upstream) → open it → Targets → New Target echo1:8080, then echo2:8080. Then create a service with Host = lb-upstream and a route /lb.

curl -s -X POST $ADMIN/upstreams --data name=lb-upstream
curl -s -X POST $ADMIN/upstreams/lb-upstream/targets --data target=echo1:8080
curl -s -X POST $ADMIN/upstreams/lb-upstream/targets --data target=echo2:8080
curl -s -X POST $ADMIN/services --data name=lb-svc --data host=lb-upstream
curl -s -X POST $ADMIN/services/lb-svc/routes --data name=lb-route --data 'paths[]=/lb'

for i in 1 2 3 4; do curl -s $PROXY/lb | head -c 80; echo; done

Verify: responses alternate between the two backends; curl -s $ADMIN/upstreams/lb-upstream/targets | jq.

Keep in mind: the Service host must exactly equal the upstream name. Targets are host:port; default weight is 100; targets are append-only history (deleting = new entry with weight 0).


Lab 14 – Weighted load balancing (canary 90/10)

Task: Send ~90% of traffic to echo1 and ~10% to echo2.

UI: Upstream → Targets → edit/add target with Weight 900 and 100.

curl -s -X POST $ADMIN/upstreams/lb-upstream/targets --data target=echo1:8080 --data weight=900
curl -s -X POST $ADMIN/upstreams/lb-upstream/targets --data target=echo2:8080 --data weight=100

for i in $(seq 1 50); do curl -s $PROXY/lb | grep -o 'echo[12]'; done | sort | uniq -c

Keep in mind: weight range is 0–65535. Adding the same host:port again supersedes the older entry. Weight 0 = no traffic.


Lab 15 – Consistent hashing (sticky by header / consumer / cookie)

Task: All requests carrying the same X-User-ID must always hit the same backend.

UI: Upstream → Edit → Algorithm consistent-hashing, Hash On header, Hash On Header X-User-ID.

curl -s -X PATCH $ADMIN/upstreams/lb-upstream \
  --data algorithm=consistent-hashing \
  --data hash_on=header \
  --data hash_on_header=X-User-ID

for i in 1 2 3 4 5; do curl -s -H 'X-User-ID: alice' $PROXY/lb | head -c 60; echo; done

Verify: identical backend every time for alice; a different user may land elsewhere.

Keep in mind: hash_on options: none, consumer, ip, header, cookie, path, query_arg, uri_capture. hash_fallback is used when the primary value is missing. Other algorithms: round-robin, least-connections, latency.


Lab 16 – Active health checks

Task: Probe /health on each target every 5 s; mark a target unhealthy after 2 failures and healthy after 2 successes.

UI: Upstream → Edit → Healthchecks → Active: HTTP path /health, Healthy interval 5, Unhealthy interval 5, Healthy successes 2, Unhealthy HTTP failures 2.

curl -s -X PATCH $ADMIN/upstreams/lb-upstream \
  --data healthchecks.active.http_path=/health \
  --data healthchecks.active.healthy.interval=5 \
  --data healthchecks.active.healthy.successes=2 \
  --data healthchecks.active.unhealthy.interval=5 \
  --data healthchecks.active.unhealthy.http_failures=2

docker stop echo2            # simulate failure
sleep 15
curl -s $ADMIN/upstreams/lb-upstream/health | jq '.data[] | {target,health}'

Verify: echo2 shows UNHEALTHY; all proxy traffic goes to echo1. Start echo2 again → HEALTHY after 2 successes.

Keep in mind: an interval of 0 disables that check (the default for active checks is 0 for unhealthy/healthy intervals in some versions – always set it explicitly). Targets are marked HEALTHCHECKS_OFF if no checks are configured.


Lab 17 – Passive health checks (circuit breaker)

Task: Mark a target unhealthy after 3 consecutive 5xx/timeouts, without sending probes.

curl -s -X PATCH $ADMIN/upstreams/lb-upstream \
  --data healthchecks.passive.unhealthy.http_failures=3 \
  --data healthchecks.passive.unhealthy.timeouts=3 \
  --data 'healthchecks.passive.unhealthy.http_statuses[]=500' \
  --data 'healthchecks.passive.unhealthy.http_statuses[]=502' \
  --data 'healthchecks.passive.unhealthy.http_statuses[]=503'

UI: Upstream → Healthchecks → Passive section.

Keep in mind: passive checks observe real traffic only, and a target that was marked unhealthy passively is not automatically recovered unless an active check is also enabled (or you call the endpoint below).

curl -s -X POST $ADMIN/upstreams/lb-upstream/targets/echo2:8080/healthy
curl -s -X POST $ADMIN/upstreams/lb-upstream/targets/echo2:8080/unhealthy

Lab 18 – Drain / remove a target without downtime

Task: Take echo2 out of rotation for maintenance.

# Option 1: set weight 0 (graceful)
curl -s -X PATCH $ADMIN/upstreams/lb-upstream/targets/echo2:8080 --data weight=0

# Option 2: delete the target
curl -s -X DELETE $ADMIN/upstreams/lb-upstream/targets/echo2:8080

curl -s $ADMIN/upstreams/lb-upstream/targets | jq

Verify: repeat the /lb loop – only echo1 answers.

Leave a Reply

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