Kong Gateway Certified Associate – Practical Lab Scenarios – Part E

Part E – Transformations and Plugin Behaviour

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 36 – request-transformer: add, rename, remove

Task: Before reaching the upstream, add header X-Env: prod, add query source=kong, remove the User-Agent header and rename X-Old to X-New.

curl -s -X POST $ADMIN/routes/orders-route/plugins --data name=request-transformer \
  --data 'config.add.headers[]=X-Env:prod' \
  --data 'config.add.querystring[]=source:kong' \
  --data 'config.remove.headers[]=User-Agent' \
  --data 'config.rename.headers[]=X-Old:X-New'

curl -s $PROXY/anything/t -H 'X-Old: 1' | jq '{headers:.headers,args:.args}'

Verify: the echoed JSON shows X-Env, X-New, args.source=kong and no User-Agent.

Keep in mind: syntax is name:value. Operations run in order remove → rename → replace → add → append. add does not overwrite an existing header, replace only changes existing ones, append adds another value.


Lab 37 – response-transformer

Task: Add X-Powered-By: Kong-Lab to responses and remove the upstream Server header.

curl -s -X POST $ADMIN/routes/orders-route/plugins --data name=response-transformer \
  --data 'config.add.headers[]=X-Powered-By:Kong-Lab' \
  --data 'config.remove.headers[]=Server'

curl -i $PROXY/anything/t | head -n 15

Keep in mind: JSON body edits use config.add.json[]=key:value; they require the upstream to return JSON. Kong adds its own Via and latency headers regardless (headers setting in kong.conf).


Lab 38 – correlation-id

Task: Every request must carry a unique X-Request-ID to the upstream and back to the client.

curl -s -X POST $ADMIN/services/orders-svc/plugins --data name=correlation-id \
  --data config.header_name=X-Request-ID \
  --data config.generator=uuid --data config.echo_downstream=true

curl -si $PROXY/anything/t | grep -i x-request-id
curl -s  $PROXY/anything/t | jq '.headers["X-Request-Id"]'

Keep in mind: if the client already supplies the header, Kong keeps it. Generators: uuid, uuid#counter, tracker.


Lab 39 – Plugin precedence in practice

Task: Global rate-limiting = 10/min, route = 5/min, consumer alice = 2/min. Predict and prove which limit applies to alice calling orders-route.

curl -s -X POST $ADMIN/plugins --data name=rate-limiting --data config.minute=10 --data config.policy=local
curl -s -X POST $ADMIN/routes/orders-route/plugins --data name=rate-limiting --data config.minute=5 --data config.policy=local
curl -s -X POST $ADMIN/consumers/alice/plugins --data name=rate-limiting --data config.minute=2 --data config.policy=local

curl -si $PROXY/anything/x -H 'apikey: alice-secret' | grep -i 'x-ratelimit-limit'

Answer: X-RateLimit-Limit-Minute: 2. Only the most specific instance runs – limits are not stacked. Remove the consumer plugin and the route’s 5 applies; remove that and the global 10 applies.

Keep in mind: the same rule explains “my global plugin is ignored on one route” – a route-level instance overrides it.


Lab 40 – Execution order and enabled / protocols / tags

Task: Explain and verify why key-auth rejects a request before rate-limiting counts it, and restrict a plugin to HTTPS only.

curl -s -X PATCH $ADMIN/plugins/<id> --data 'protocols[]=https' --data enabled=true
curl -s $ADMIN/plugins/<id> | jq '{name,enabled,protocols,tags}'

Concept: plugins run in a fixed priority order (highest first), e.g. cors (2000) → jwt (1450) → key-auth (1250) → basic-auth (1100) → ip-restriction (990) → acl (950) → rate-limiting (910) → request-transformer (801) → response-transformer (800) → proxy-cache (100) → loggers (last). Values are approximate – know the relative order. Custom ordering (ordering field) is Enterprise-only.

Keep in mind: unauthenticated calls are rejected with 401 and therefore do not consume the consumer’s rate-limit quota.

Leave a Reply

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