Kong Gateway Certified Associate – Practical Lab Scenarios – Part G

Part G – Configuration Management, Admin and Operations

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 45 – Declarative config with decK

Task: Export the current config, add a service in YAML, preview and apply it.

deck gateway ping --kong-addr $ADMIN
deck gateway dump -o kong.yaml --kong-addr $ADMIN       # older decK: deck dump

kong.yaml (add to the file):

_format_version: "3.0"
services:
  - name: deck-svc
    url: http://httpbin.org
    routes:
      - name: deck-route
        paths: [/deck]
    plugins:
      - name: rate-limiting
        config: { minute: 3, policy: local }
deck gateway validate kong.yaml
deck gateway diff kong.yaml --kong-addr $ADMIN      # preview (+ create, ~ update, - delete)
deck gateway sync kong.yaml --kong-addr $ADMIN       # apply
curl -i $PROXY/deck/get

Keep in mind: sync deletes anything not in the file – always run diff first or use --select-tag to limit scope. Use --workspace team-a for EE workspaces and --headers 'Kong-Admin-Token:xxx' when RBAC is on.


Lab 46 – DB-less mode

Task: Run Kong without a database from a kong.yml, then change config.

export KONG_DATABASE=off
export KONG_DECLARATIVE_CONFIG=/etc/kong/kong.yml
kong config parse /etc/kong/kong.yml     # syntax/schema validation
kong start                               # or: kong reload after edits

curl -i -X POST $ADMIN/services --data name=x --data url=http://a.b   # 405 – read-only
curl -s -X POST $ADMIN/config -F config=@/etc/kong/kong.yml           # hot-load new config
curl -s $ADMIN/config | jq -r .config | head

Keep in mind: in DB-less mode there are no consumers’ runtime changes, no cluster-policy rate-limiting and no plugins that write to the DB (e.g. OAuth2 token issuing). A bad kong.yml is rejected with a 400 and the old config keeps running.


Lab 47 – Workspaces [EE]

Task: Create workspace team-a, add a service there and prove isolation.

UI: Overview → New Workspace team-a → enter it → Gateway Services → New.

curl -s -X POST $ADMIN/workspaces --data name=team-a
curl -s -X POST $ADMIN/team-a/services --data name=svc-a --data url=http://httpbin.org
curl -s -X POST $ADMIN/team-a/services/svc-a/routes --data name=r-a --data 'paths[]=/ta'

curl -s $ADMIN/services     | jq '.data[].name'   # default workspace: does not list svc-a
curl -s $ADMIN/team-a/services | jq '.data[].name'

Keep in mind: names are unique per workspace, but route paths/hosts must still not conflict across workspaces (proxy is shared). Deleting a workspace requires it to be empty. The URL pattern is /{workspace}/{entity}.


Lab 48 – RBAC [EE]

Task: A user ops1 may only read services in team-a.

# Enforce RBAC (kong.conf / env) then restart: KONG_ENFORCE_RBAC=on
curl -s -X POST $ADMIN/rbac/roles --data name=team-a-read -H 'Kong-Admin-Token: <super-admin>'
curl -s -X POST $ADMIN/rbac/roles/team-a-read/endpoints \
  --data workspace=team-a --data endpoint=/services --data actions=read -H 'Kong-Admin-Token: <super-admin>'
curl -s -X POST $ADMIN/rbac/users --data name=ops1 --data user_token=ops1-token -H 'Kong-Admin-Token: <super-admin>'
curl -s -X POST $ADMIN/rbac/users/ops1/roles --data roles=team-a-read -H 'Kong-Admin-Token: <super-admin>'

curl -i $ADMIN/team-a/services -H 'Kong-Admin-Token: ops1-token'                      # 200
curl -i -X POST $ADMIN/team-a/services -H 'Kong-Admin-Token: ops1-token' ...          # 403

UI: Teams → RBAC Users/Roles → create role → add endpoint permission → assign to user. Kong Manager login uses an Admin (/admins), not just an RBAC user.

Keep in mind: endpoint=* + actions=read,create,update,delete = full access; negative permissions (negative=true) override positives. Wrong/missing token → 401; insufficient permission → 403.


Lab 49 – TLS: certificate, SNI and HTTPS-only routes

Task: Serve api.example.com over HTTPS with your own certificate, and force HTTP clients to upgrade.

curl -s -X POST $ADMIN/certificates \
  -F cert=@api.crt -F key=@api.key -F 'snis[]=api.example.com'

curl -s -X PATCH $ADMIN/routes/orders-route \
  --data 'protocols[]=https' --data 'hosts[]=api.example.com' \
  --data https_redirect_status_code=301

curl -ik --resolve api.example.com:8443:127.0.0.1 https://api.example.com:8443/anything/x   # 200
curl -i  -H 'Host: api.example.com' http://localhost:8000/anything/x                        # 301/426

Verify cert in use: openssl s_client -connect localhost:8443 -servername api.example.com </dev/null | openssl x509 -noout -subject.

Keep in mind: the SNI must match the TLS server name, otherwise Kong serves its default self-signed cert. For upstream TLS use service.protocol=https and, for mTLS, client_certificate, tls_verify, ca_certificates.


Lab 50 – Hybrid mode: Control Plane and Data Plane

Task: Start a CP with a DB and a DP without one; prove config propagates.

kong hybrid gen_cert cluster.crt cluster.key      # shared mTLS pair (or use a CA)

# Control plane
KONG_ROLE=control_plane KONG_DATABASE=postgres KONG_CLUSTER_CERT=cluster.crt \
 KONG_CLUSTER_CERT_KEY=cluster.key KONG_CLUSTER_LISTEN=0.0.0.0:8005 \
 KONG_CLUSTER_TELEMETRY_LISTEN=0.0.0.0:8006 kong start

# Data plane
KONG_ROLE=data_plane KONG_DATABASE=off KONG_CLUSTER_CONTROL_PLANE=cp:8005 \
 KONG_CLUSTER_TELEMETRY_ENDPOINT=cp:8006 KONG_CLUSTER_CERT=cluster.crt \
 KONG_CLUSTER_CERT_KEY=cluster.key kong start

curl -s $ADMIN/clustering/data-planes | jq '.data[]|{hostname,ip,status:.sync_status}'

UI: Kong Manager → Data Plane Nodes (shows connected DPs and last-seen).

Keep in mind: configure services/routes only on the CP Admin API; the DP proxies traffic and has no Admin API for writes. Rate-limiting policy=cluster is not supported on DPs – use local or redis. DPs keep serving the last known config if the CP is down.


Lab 51 – Kong CLI and configuration precedence

Task: Move the proxy to port 9000 and enable debug logging, using an environment variable, then verify.

kong version
kong check /etc/kong/kong.conf                 # validate kong.conf
KONG_PROXY_LISTEN=0.0.0.0:9000 KONG_LOG_LEVEL=debug kong reload
ss -ltnp | grep 9000
curl -s $ADMIN/ | jq '.configuration.proxy_listen, .configuration.log_level'
kong stop      # fast shutdown;  kong quit = graceful

Keep in mind: precedence is environment variable KONG_* > kong.conf > defaults. kong reload re-reads config without dropping connections; a plain edit of kong.conf has no effect until reload/restart. Prefix dir default /usr/local/kong.


Lab 52 – Systematic troubleshooting (404 / 502 / 503 / 504 / 500)

Task: Given a failing request, find the root cause in under two minutes.

SymptomMost likely causeQuick check / fix
404 no Route matched with those valuesPath, host, method, header or protocol mismatch; wrong strip_pathGET /routes, curl -v with correct Host
404 from the upstream body (not Kong JSON)Route matched, upstream path wrongstrip_path, service.path, curl upstream directly
502 An invalid response was received from the upstream serverUpstream down, port wrong, TLS mismatch (http vs https)service.protocol/port, curl upstream from the Kong host
503 name resolution failed / failure to get a peer from the balancerBad DNS name, no healthy targets, service host not equal to upstream name/upstreams/<n>/health, DNS inside the container
504 The upstream server is timing outSlow upstream vs read_timeoutRaise timeouts / fix upstream
500 An unexpected error occurredPlugin config / Lua errorerror.log at notice/debug
401 / 403Auth / ACL / IP pluginLab 27
429Rate limitCheck RateLimit-* headers and plugin scope
docker exec kong tail -n 50 /usr/local/kong/logs/error.log
curl -sv $PROXY/anything/x 2>&1 | grep -E '^< (HTTP|X-Kong|Via)'

Keep in mind: the headers X-Kong-Upstream-Latency (present = Kong reached the upstream) vs absent (Kong never got a response) separate route/auth problems from upstream problems.


Lab 53 – Database migrations (install and upgrade)

Task: Prepare a fresh Postgres and later upgrade Kong with minimal downtime.

kong migrations bootstrap -c kong.conf      # fresh install only
kong migrations list                         # which are executed / pending

# Upgrade 3.x -> 3.y
kong migrations up                           # non-breaking, old nodes keep running
# roll out new Kong nodes ...
kong migrations finish                       # completes breaking changes

Keep in mind: bootstrap on an already-initialised DB fails; Kong refuses to start if migrations are pending (database needs updating). Kong 3.x supports PostgreSQL only (Cassandra removed). Take a DB backup first.


Lab 54 – Mini mock exam (45 minutes)

Do all of this from scratch, with evidence for each item (a curl -i output or Admin API GET):

  1. Create shop-svc → http://httpbin.org, route /shop, strip_path=false; prove with /shop/anything or /anything.
  2. Create upstream shop-up with two targets, weights 70/30, service host = shop-up.
  3. Add active health check on /status/200 every 5 s; stop one target and show UNHEALTHY.
  4. Add key-auth on the service, consumers u1 and u2, custom header X-API-Key, hide_credentials=true.
  5. Add acl allowing only group vip; u1 in vip, u2 not → 200 vs 403.
  6. Add rate-limiting 3/min on the route; u1 gets 10/min via a consumer-scoped plugin.
  7. Add request-transformer adding X-Source: exam and response-transformer adding X-Lab: done.
  8. Add correlation-id and file-log and show one JSON log line containing the request id.
  9. Export everything with deck gateway dump and show that a diff against a clean node would recreate it.
  10. Break something on purpose (wrong service port) and diagnose it with status code + error.log.

Exam-day strategy

  • Read the exact entity names and values in the task (route name, header name, port). A typo = a failed check.
  • Always verify with curl -i after every change and keep the command history (history) – it proves the work.
  • Check scope first: service vs route vs consumer vs global; most “plugin not working” tasks are scope mistakes.
  • Remember the defaults: strip_path=true, preserve_host=false, timeouts 60 s, retries 5, upstream weight 100, limit_by=consumer, policy=local is not shared between nodes.
  • Know both interfaces: Kong Manager for quick visual tasks, Admin API/decK for repeatable ones; field names are the same in both (config.minute = Minute field in the UI).
  • 404 = route problem, 401/403 = auth problem, 502/503/504 = upstream problem. Start there.
  • Time-box: if a task takes > 5 minutes, move on and return later.
  • Practise with the official docs open (docs.konghq.com plugin pages list every parameter and default) – learn where parameters are documented rather than memorising everything.

Leave a Reply

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