A lookup reference for the hands-on lab: decK, Admin API, kong CLI, Docker/Linux troubleshooting, and Enterprise admin. It is a companion to the article “Kong Gateway Certified Associate – Lab Exam Command-Line Guide”.
Kong Gateway Associate – Master Command Reference and Cheat Sheet
A caveat first: nobody outside the exam can list every command it asks, so this covers the full toolset the public objectives point to. If a task uses something outside it, fall back on --help and GET /schemas/plugins/<name>.
1. Notes on version differences
- decK flag style depends on the version. Newer decK takes the state file as a positional argument (
deck gateway sync kong.yaml). Older and some current builds use-s(deck gateway sync -s kong.yaml). Rundeck gateway sync --helponce and copy the form it shows. deck gateway resetasks for confirmation and needs--forceto skip it. It deletes everything it can reach, so scope it (--select-tag) or avoid it in an exam.kong reloaddoes not apply entity changes. Services, routes and plugins live in the database or declarative config. Reload is forkong.confor environment changes, and for reloading a declarative file in DB-less mode.kong restartdrops connections. Preferkong reload, andkong quitfor a graceful stop.- Old command names (
deck ping,deck dump,deck sync) still appear in tutorials and may work on older builds.
2. decK complete reference
| Goal | Command |
|---|---|
| Version | deck version |
| Test connection | deck gateway ping |
| Export all state | deck gateway dump -o kong.yaml |
| Export as JSON | deck gateway dump --format json -o kong.json |
| Export with IDs | deck gateway dump --with-id -o kong.yaml |
| Export only tagged | deck gateway dump --select-tag lab1 -o lab1.yaml |
| Skip consumers | deck gateway dump --skip-consumers -o kong.yaml |
| Export one workspace | deck gateway dump --workspace team-a -o team-a.yaml |
| Validate | deck gateway validate kong.yaml |
| Preview | deck gateway diff kong.yaml |
| Apply | deck gateway sync kong.yaml |
| Apply scoped | deck gateway sync kong.yaml --select-tag lab1 |
| Wipe | deck gateway reset --force |
| Point at another node | --kong-addr http://host:8001 on any command |
| RBAC token | --headers 'Kong-Admin-Token: <token>' |
| Verbose | --verbose 2 |
| Merge files | deck file merge a.yaml b.yaml -o all.yaml |
| OpenAPI to Kong | deck file openapi2kong -s api.yaml -o kong.yaml |
| Convert formats | deck file convert --from kong-gateway-2.x --to kong-gateway-3.x kong.yaml |
Entity keys in a decK file
| Top-level key | Contains |
|---|---|
_format_version | "3.0" (older files use "1.1") |
_workspace | Target workspace name |
_info.select_tags | Tags scoping what this file manages |
services | Services with nested routes and plugins |
routes | Top-level routes referencing service: name |
plugins | Plugins, each scoped by service, route or consumer |
consumers | With keyauth_credentials, basicauth_credentials, jwt_secrets, acls, plugins |
upstreams | With nested targets |
certificates | With snis |
consumer_groups | Enterprise consumer groups |
A complete worked file
_format_version: "3.0"
_info:
select_tags: [lab1]
services:
- name: orders
url: http://orders-upstream
tags: [lab1]
routes:
- name: orders-route
paths: [/orders]
strip_path: true
tags: [lab1]
plugins:
- name: key-auth
tags: [lab1]
- name: rate-limiting
config: {minute: 5, policy: local}
tags: [lab1]
upstreams:
- name: orders-upstream
algorithm: round-robin
targets:
- {target: "orders-v1:8080", weight: 90}
- {target: "orders-v2:8080", weight: 10}
consumers:
- username: alice
tags: [lab1]
keyauth_credentials: [{key: alice-secret}]
acls: [{group: gold}]
Routine: deck gateway validate, then deck gateway diff, then deck gateway sync, then a curl through port 8000 to prove it.
3. Admin API master table
Base URL http://localhost:8001. Replace {x} with an id or name.
| Entity | List / read | Create | Update | Delete |
|---|---|---|---|---|
| Service | GET /services, GET /services/{s} | POST /services | PATCH /services/{s} | DELETE /services/{s} |
| Route | GET /routes, GET /services/{s}/routes | POST /services/{s}/routes or POST /routes | PATCH /routes/{r} | DELETE /routes/{r} |
| Consumer | GET /consumers | POST /consumers | PATCH /consumers/{c} | DELETE /consumers/{c} |
| Plugin | GET /plugins, GET /plugins/{id} | POST /plugins, /services/{s}/plugins, /routes/{r}/plugins, /consumers/{c}/plugins | PATCH /plugins/{id} | DELETE /plugins/{id} |
| Upstream | GET /upstreams, /upstreams/{u}/health | POST /upstreams | PATCH /upstreams/{u} | DELETE /upstreams/{u} |
| Target | GET /upstreams/{u}/targets | POST /upstreams/{u}/targets | add a new entry | DELETE /upstreams/{u}/targets/{t} |
| Certificate | GET /certificates | POST /certificates | PATCH /certificates/{id} | DELETE /certificates/{id} |
| SNI | GET /snis | POST /snis | PATCH /snis/{id} | DELETE /snis/{id} |
| Workspace | GET /workspaces | POST /workspaces | PATCH /workspaces/{w} | DELETE /workspaces/{w} |
| Tags | GET /tags, GET /tags/{tag} | via tags= on entities | PATCH entity | DELETE entity |
Credentials per consumer
| Type | Create |
|---|---|
| Key auth | POST /consumers/{c}/key-auth key=<k> |
| Basic auth | POST /consumers/{c}/basic-auth username=<u> password=<p> |
| JWT | POST /consumers/{c}/jwt key=<iss> secret=<s> algorithm=HS256 |
| HMAC | POST /consumers/{c}/hmac-auth username=<u> secret=<s> |
| OAuth2 app | POST /consumers/{c}/oauth2 name=<n> client_id=<id> client_secret=<s> redirect_uris=<uri> |
| ACL group | POST /consumers/{c}/acls group=<g> |
List credentials with GET /consumers/{c}/key-auth (and the same pattern for the others), or GET /key-auths globally.
Operational and information endpoints
| Purpose | Request |
|---|---|
| Node info, version, config | GET / |
| Connections and DB reachability | GET /status |
| Enabled plugins | GET /plugins/enabled |
| Plugin field definitions | GET /schemas/plugins/{name} |
| Entity schema | GET /schemas/services |
| Validate a plugin config | POST /schemas/plugins/validate name=rate-limiting config.minute=5 |
| All endpoints | GET /endpoints |
| Prometheus metrics | GET /metrics (plugin enabled) |
| Load DB-less config | POST /config with -F config=@kong.yaml |
| Dump DB-less config | GET /config |
| Change log level live | PUT /debug/node/log-level/debug (revert with /notice) |
| Hybrid data planes | GET /clustering/data-planes |
| Hybrid health | GET /clustering/status |
Update semantics you must remember
PUTcreates or fully replaces; fields you omit return to defaults.PATCHchanges only the fields you send.- Arrays are replaced wholesale: to add one path you must send them all, for example
--data 'paths[]=/a' --data 'paths[]=/b'. - Form data (
--data) and JSON (-H 'Content-Type: application/json' -d '{...}') both work; use JSON for nested config.
curl -s -X POST localhost:8001/services/orders/plugins \
-H 'Content-Type: application/json' \
-d '{"name":"rate-limiting","config":{"minute":5,"policy":"local"}}'
4. Plugin quick reference
| Plugin | Minimal enable | Typical test |
|---|---|---|
key-auth | name=key-auth | 401 without key, 200 with apikey header |
basic-auth | name=basic-auth | curl -u user:pass |
jwt | name=jwt | Authorization: Bearer <token> |
acl | name=acl config.allow[]=group | 403 for consumers outside the group |
rate-limiting | config.minute=5 config.policy=local | 6th request returns 429 |
request-termination | config.status_code=503 config.message=down | Instant maintenance response |
request-transformer | config.add.headers[]=K:V | Echo endpoint shows header |
response-transformer | config.add.headers[]=K:V | Header in response |
cors | config.origins[]=* | Preflight OPTIONS with Origin header |
ip-restriction | config.allow[]=1.2.3.4 | 403 from other IPs |
proxy-cache | config.strategy=memory | X-Cache-Status: Miss then Hit |
correlation-id | config.header_name=X-Request-ID | Unique id per request |
request-size-limiting | config.allowed_payload_size=1 | 413 over the limit |
file-log | config.path=/tmp/k.log | tail the file |
http-log | config.http_endpoint=http://host:port | Collector receives JSON |
prometheus | name=prometheus | GET /metrics |
canary (Ent) | config.percentage=10 config.upstream_host=... | Count responses by version |
Useful request-termination trick: apply it to a route to simulate maintenance mode, remove it afterwards.
5. The kong CLI complete reference
| Command | Purpose |
|---|---|
kong version | Print the version |
kong start [-c kong.conf] [--vv] | Start; --vv for debug output |
kong stop | Stop immediately |
kong quit | Graceful stop, finishing in-flight requests |
kong restart | Stop then start |
kong reload | Reload configuration with no downtime |
kong health | Check the node and its processes |
kong check kong.conf | Validate a configuration file |
kong prepare | Prepare the prefix directory without starting |
kong config init | Write a starter kong.yml |
kong config parse kong.yml | Validate a declarative file |
kong config db_import kong.yml | Import a declarative file into the database |
kong config db_export kong.yml | Export database content to a file |
kong migrations bootstrap | First-time schema creation |
kong migrations up | Run pending non-destructive migrations |
kong migrations finish | Complete pending migrations after up |
kong migrations list | Show migration state |
kong migrations reset | Drop all data (dangerous) |
kong vault get {reference} | Test a vault reference |
Useful options: -p /usr/local/kong (prefix), -c /etc/kong/kong.conf, --v and --vv verbosity.
Frequently tested kong.conf and environment settings
kong.conf key | Environment variable | Meaning |
|---|---|---|
database | KONG_DATABASE | postgres or off |
declarative_config | KONG_DECLARATIVE_CONFIG | Path to the DB-less file |
pg_host, pg_user, pg_password, pg_database | KONG_PG_* | Postgres connection |
proxy_listen | KONG_PROXY_LISTEN | Proxy addresses and ports |
admin_listen | KONG_ADMIN_LISTEN | Admin API address |
admin_gui_url | KONG_ADMIN_GUI_URL | Kong Manager URL |
status_listen | KONG_STATUS_LISTEN | Read-only status and metrics port |
log_level | KONG_LOG_LEVEL | debug, info, notice, warn, error |
plugins | KONG_PLUGINS | bundled or a custom list |
role | KONG_ROLE | traditional, control_plane, data_plane |
enforce_rbac | KONG_ENFORCE_RBAC | Enable RBAC (Enterprise) |
license_data | KONG_LICENSE_DATA | Enterprise license (older: KONG_LICENSE_PATH) |
After changing environment variables on a container you must recreate the container; a reload alone will not see new Docker environment values.
6. Docker, Compose and Linux troubleshooting
| Goal | Command |
|---|---|
| Running containers | docker ps (add -a for stopped) |
| Logs | docker logs kong, docker logs -f --tail 100 kong |
| Shell inside | docker exec -it kong sh |
| Run a Kong command | docker exec kong kong health |
| Container env | docker exec kong env | grep KONG_ |
| Inspect network and IPs | docker inspect kong | jq '.[0].NetworkSettings' |
| Which network | docker network ls, docker network inspect kong-net |
| Restart | docker restart kong |
| Compose up / down | docker compose up -d, docker compose down |
| Compose logs / status | docker compose logs -f kong, docker compose ps |
| Port in use | ss -ltnp | grep 8000 |
| Upstream reachable from Kong | docker exec kong curl -i http://orders-v1:8080/health |
| DNS from Kong | docker exec kong getent hosts orders-v1 |
| Edit the YAML | vi kong.yaml or nano kong.yaml |
| Validate YAML | python3 -c 'import yaml,sys;yaml.safe_load(open("kong.yaml"))' |
Useful curl flags: -i headers, -s quiet, -o /dev/null -w '%{http_code}\n' status only, -H header, -u basic auth, -k skip TLS verification, --resolve host:port:ip fake DNS, -X method, -d body, -L follow redirects, -v verbose.
Request-counting snippets
# Status code distribution
for i in $(seq 1 20); do curl -s -o /dev/null -w '%{http_code}\n' localhost:8000/orders; done | sort | uniq -c
# Version distribution for a canary
for i in $(seq 1 100); do curl -s localhost:8000/orders | jq -r .version; done | sort | uniq -c
# Rate limit headers
curl -si localhost:8000/orders -H 'apikey: alice-secret' | grep -i '^x-ratelimit'
7. Kubernetes variant (only if your lab uses it)
The Kong Ingress Controller route is a separate Kong badge, but if your environment is Kubernetes the equivalents are:
| Goal | Command |
|---|---|
| Pods and services | kubectl get pods,svc -n kong |
| Logs | kubectl logs deploy/kong-gateway -n kong -c proxy |
| Apply a manifest | kubectl apply -f ingress.yaml |
| List Kong resources | kubectl get kongplugins,kongconsumers,kongingress |
| Describe a problem | kubectl describe ingress my-ingress |
| Port-forward Admin API | kubectl port-forward -n kong svc/kong-admin 8001:8001 |
Plugins attach with the annotation konghq.com/plugins: my-plugin on an Ingress or Service, referencing a KongPlugin resource.
8. Status code diagnosis
| Code | Meaning in Kong | First thing to check |
|---|---|---|
| 200 | Success | Confirm it hit the right route |
| 400 | Bad request, e.g. invalid header | Request format |
| 401 | Authentication failed or missing | Is the plugin attached, is the key valid and in the right header |
| 403 | Authenticated but not allowed | ACL groups, IP restriction |
| 404 | no Route matched | Path, host, method, strip_path, stray trailing slash |
| 413 | Payload too large | request-size-limiting |
| 429 | Rate limited | rate-limiting config and scope |
| 500 | Kong or plugin error | docker logs kong, plugin configuration |
| 502 | Bad response from upstream | Upstream running, correct port and protocol |
| 503 | No healthy target or service unavailable | GET /upstreams/{u}/health, DNS |
| 504 | Upstream timeout | Service read_timeout, upstream speed |
9. Scenario walkthroughs
Scenario A: A route returns 502
curl -i localhost:8000/ordersconfirms the 502.curl -s localhost:8001/services/orders | jq '{host,port,protocol,path}'shows where Kong forwards.docker psto see whether the upstream container is running.docker exec kong curl -i http://<host>:<port>/tests reachability from Kong’s own network.docker logs --tail 50 kongoften names the cause, for example connection refused or DNS failure.- Fix the service with
PATCH /services/orders --data host=... --data port=..., then re-test through port 8000.
Scenario B: Rate limiting with decK
_format_version: "3.0"
services:
- name: orders
url: http://httpbin.org
routes:
- name: orders-route
paths: [/orders]
plugins:
- name: rate-limiting
config:
minute: 3
policy: local
deck gateway validate kong.yaml
deck gateway diff kong.yaml
deck gateway sync kong.yaml
for i in $(seq 1 5); do curl -s -o /dev/null -w '%{http_code}\n' localhost:8000/orders/get; done
# Expect 200 200 200 429 429
Scenario C: Protect a route and prove it
curl -X POST localhost:8001/routes/orders-route/plugins --data name=key-auth
curl -X POST localhost:8001/consumers --data username=alice
curl -X POST localhost:8001/consumers/alice/key-auth --data key=k1
curl -s -o /dev/null -w '%{http_code}\n' localhost:8000/orders/get # 401
curl -s -o /dev/null -w '%{http_code}\n' localhost:8000/orders/get -H 'apikey: k1' # 200
curl -s -o /dev/null -w '%{http_code}\n' localhost:8000/orders/get -H 'apikey: bad' # 401
Scenario D: Fix a broken plugin scope
Symptom: alice is rate-limited at 5 per minute even though she should have 100. Cause: the consumer-scoped plugin was created on the wrong consumer or the service-level plugin is the only one that exists. Check GET /plugins | jq '.data[] | {name, service, route, consumer, config: .config.minute}', then create the consumer-scoped instance with POST /consumers/alice/plugins.
Scenario E: Move a DB-backed setup to DB-less
deck gateway dump -o kong.yaml
docker run -d --name kong-dbless -e KONG_DATABASE=off \
-e KONG_DECLARATIVE_CONFIG=/kong/kong.yaml -v $(pwd)/kong.yaml:/kong/kong.yaml \
-p 8000:8000 -p 8001:8001 kong/kong-gateway:3.4
curl -s localhost:8001/services | jq '.data | length'
Note the declarative file in DB-less mode must use _format_version, and the Admin API becomes read-only for entities.
10. Master cheat sheet (print this)
decK: ping, then dump -o f.yaml, edit, validate, diff, sync. Scope with --select-tag. Always deck gateway <cmd> unless the version is old.
Create chain: service, route, plugin, consumer, credential, then test on 8000.
Scoping: /plugins global, /services/{s}/plugins, /routes/{r}/plugins, /consumers/{c}/plugins. Most specific wins.
Auth recipe: key-auth on route, POST /consumers, POST /consumers/{c}/key-auth, header apikey. Add acl plus POST /consumers/{c}/acls group=.
Balance recipe: POST /upstreams, POST /upstreams/{u}/targets target=host:port weight=n, service host=<upstream name>.
Health: GET /upstreams/{u}/health, POST .../targets/{t}/unhealthy, .../healthy.
Observe: file-log or http-log, prometheus then GET /metrics, docker logs.
CLI: kong health, kong check, kong reload, kong config parse, kong migrations list.
Discover when stuck: GET /plugins/enabled, GET /schemas/plugins/{name}, GET /endpoints, deck --help, kong --help.
Verify: every change ends with a request through port 8000 and an expected status code.