Kong Gateway Associate – Master Command Reference and Cheat Sheet

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). Run deck gateway sync --help once and copy the form it shows.
  • deck gateway reset asks for confirmation and needs --force to skip it. It deletes everything it can reach, so scope it (--select-tag) or avoid it in an exam.
  • kong reload does not apply entity changes. Services, routes and plugins live in the database or declarative config. Reload is for kong.conf or environment changes, and for reloading a declarative file in DB-less mode.
  • kong restart drops connections. Prefer kong reload, and kong quit for 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

GoalCommand
Versiondeck version
Test connectiondeck gateway ping
Export all statedeck gateway dump -o kong.yaml
Export as JSONdeck gateway dump --format json -o kong.json
Export with IDsdeck gateway dump --with-id -o kong.yaml
Export only taggeddeck gateway dump --select-tag lab1 -o lab1.yaml
Skip consumersdeck gateway dump --skip-consumers -o kong.yaml
Export one workspacedeck gateway dump --workspace team-a -o team-a.yaml
Validatedeck gateway validate kong.yaml
Previewdeck gateway diff kong.yaml
Applydeck gateway sync kong.yaml
Apply scopeddeck gateway sync kong.yaml --select-tag lab1
Wipedeck 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 filesdeck file merge a.yaml b.yaml -o all.yaml
OpenAPI to Kongdeck file openapi2kong -s api.yaml -o kong.yaml
Convert formatsdeck file convert --from kong-gateway-2.x --to kong-gateway-3.x kong.yaml

Entity keys in a decK file

Top-level keyContains
_format_version"3.0" (older files use "1.1")
_workspaceTarget workspace name
_info.select_tagsTags scoping what this file manages
servicesServices with nested routes and plugins
routesTop-level routes referencing service: name
pluginsPlugins, each scoped by service, route or consumer
consumersWith keyauth_credentials, basicauth_credentials, jwt_secrets, acls, plugins
upstreamsWith nested targets
certificatesWith snis
consumer_groupsEnterprise 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.

EntityList / readCreateUpdateDelete
ServiceGET /services, GET /services/{s}POST /servicesPATCH /services/{s}DELETE /services/{s}
RouteGET /routes, GET /services/{s}/routesPOST /services/{s}/routes or POST /routesPATCH /routes/{r}DELETE /routes/{r}
ConsumerGET /consumersPOST /consumersPATCH /consumers/{c}DELETE /consumers/{c}
PluginGET /plugins, GET /plugins/{id}POST /plugins, /services/{s}/plugins, /routes/{r}/plugins, /consumers/{c}/pluginsPATCH /plugins/{id}DELETE /plugins/{id}
UpstreamGET /upstreams, /upstreams/{u}/healthPOST /upstreamsPATCH /upstreams/{u}DELETE /upstreams/{u}
TargetGET /upstreams/{u}/targetsPOST /upstreams/{u}/targetsadd a new entryDELETE /upstreams/{u}/targets/{t}
CertificateGET /certificatesPOST /certificatesPATCH /certificates/{id}DELETE /certificates/{id}
SNIGET /snisPOST /snisPATCH /snis/{id}DELETE /snis/{id}
WorkspaceGET /workspacesPOST /workspacesPATCH /workspaces/{w}DELETE /workspaces/{w}
TagsGET /tags, GET /tags/{tag}via tags= on entitiesPATCH entityDELETE entity

Credentials per consumer

TypeCreate
Key authPOST /consumers/{c}/key-auth key=<k>
Basic authPOST /consumers/{c}/basic-auth username=<u> password=<p>
JWTPOST /consumers/{c}/jwt key=<iss> secret=<s> algorithm=HS256
HMACPOST /consumers/{c}/hmac-auth username=<u> secret=<s>
OAuth2 appPOST /consumers/{c}/oauth2 name=<n> client_id=<id> client_secret=<s> redirect_uris=<uri>
ACL groupPOST /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

PurposeRequest
Node info, version, configGET /
Connections and DB reachabilityGET /status
Enabled pluginsGET /plugins/enabled
Plugin field definitionsGET /schemas/plugins/{name}
Entity schemaGET /schemas/services
Validate a plugin configPOST /schemas/plugins/validate name=rate-limiting config.minute=5
All endpointsGET /endpoints
Prometheus metricsGET /metrics (plugin enabled)
Load DB-less configPOST /config with -F config=@kong.yaml
Dump DB-less configGET /config
Change log level livePUT /debug/node/log-level/debug (revert with /notice)
Hybrid data planesGET /clustering/data-planes
Hybrid healthGET /clustering/status

Update semantics you must remember

  • PUT creates or fully replaces; fields you omit return to defaults.
  • PATCH changes 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

PluginMinimal enableTypical test
key-authname=key-auth401 without key, 200 with apikey header
basic-authname=basic-authcurl -u user:pass
jwtname=jwtAuthorization: Bearer <token>
aclname=acl config.allow[]=group403 for consumers outside the group
rate-limitingconfig.minute=5 config.policy=local6th request returns 429
request-terminationconfig.status_code=503 config.message=downInstant maintenance response
request-transformerconfig.add.headers[]=K:VEcho endpoint shows header
response-transformerconfig.add.headers[]=K:VHeader in response
corsconfig.origins[]=*Preflight OPTIONS with Origin header
ip-restrictionconfig.allow[]=1.2.3.4403 from other IPs
proxy-cacheconfig.strategy=memoryX-Cache-Status: Miss then Hit
correlation-idconfig.header_name=X-Request-IDUnique id per request
request-size-limitingconfig.allowed_payload_size=1413 over the limit
file-logconfig.path=/tmp/k.logtail the file
http-logconfig.http_endpoint=http://host:portCollector receives JSON
prometheusname=prometheusGET /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

CommandPurpose
kong versionPrint the version
kong start [-c kong.conf] [--vv]Start; --vv for debug output
kong stopStop immediately
kong quitGraceful stop, finishing in-flight requests
kong restartStop then start
kong reloadReload configuration with no downtime
kong healthCheck the node and its processes
kong check kong.confValidate a configuration file
kong preparePrepare the prefix directory without starting
kong config initWrite a starter kong.yml
kong config parse kong.ymlValidate a declarative file
kong config db_import kong.ymlImport a declarative file into the database
kong config db_export kong.ymlExport database content to a file
kong migrations bootstrapFirst-time schema creation
kong migrations upRun pending non-destructive migrations
kong migrations finishComplete pending migrations after up
kong migrations listShow migration state
kong migrations resetDrop 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 keyEnvironment variableMeaning
databaseKONG_DATABASEpostgres or off
declarative_configKONG_DECLARATIVE_CONFIGPath to the DB-less file
pg_host, pg_user, pg_password, pg_databaseKONG_PG_*Postgres connection
proxy_listenKONG_PROXY_LISTENProxy addresses and ports
admin_listenKONG_ADMIN_LISTENAdmin API address
admin_gui_urlKONG_ADMIN_GUI_URLKong Manager URL
status_listenKONG_STATUS_LISTENRead-only status and metrics port
log_levelKONG_LOG_LEVELdebug, info, notice, warn, error
pluginsKONG_PLUGINSbundled or a custom list
roleKONG_ROLEtraditional, control_plane, data_plane
enforce_rbacKONG_ENFORCE_RBACEnable RBAC (Enterprise)
license_dataKONG_LICENSE_DATAEnterprise 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

GoalCommand
Running containersdocker ps (add -a for stopped)
Logsdocker logs kong, docker logs -f --tail 100 kong
Shell insidedocker exec -it kong sh
Run a Kong commanddocker exec kong kong health
Container envdocker exec kong env | grep KONG_
Inspect network and IPsdocker inspect kong | jq '.[0].NetworkSettings'
Which networkdocker network ls, docker network inspect kong-net
Restartdocker restart kong
Compose up / downdocker compose up -d, docker compose down
Compose logs / statusdocker compose logs -f kong, docker compose ps
Port in usess -ltnp | grep 8000
Upstream reachable from Kongdocker exec kong curl -i http://orders-v1:8080/health
DNS from Kongdocker exec kong getent hosts orders-v1
Edit the YAMLvi kong.yaml or nano kong.yaml
Validate YAMLpython3 -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:

GoalCommand
Pods and serviceskubectl get pods,svc -n kong
Logskubectl logs deploy/kong-gateway -n kong -c proxy
Apply a manifestkubectl apply -f ingress.yaml
List Kong resourceskubectl get kongplugins,kongconsumers,kongingress
Describe a problemkubectl describe ingress my-ingress
Port-forward Admin APIkubectl 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

CodeMeaning in KongFirst thing to check
200SuccessConfirm it hit the right route
400Bad request, e.g. invalid headerRequest format
401Authentication failed or missingIs the plugin attached, is the key valid and in the right header
403Authenticated but not allowedACL groups, IP restriction
404no Route matchedPath, host, method, strip_path, stray trailing slash
413Payload too largerequest-size-limiting
429Rate limitedrate-limiting config and scope
500Kong or plugin errordocker logs kong, plugin configuration
502Bad response from upstreamUpstream running, correct port and protocol
503No healthy target or service unavailableGET /upstreams/{u}/health, DNS
504Upstream timeoutService read_timeout, upstream speed

9. Scenario walkthroughs

Scenario A: A route returns 502

  1. curl -i localhost:8000/orders confirms the 502.
  2. curl -s localhost:8001/services/orders | jq '{host,port,protocol,path}' shows where Kong forwards.
  3. docker ps to see whether the upstream container is running.
  4. docker exec kong curl -i http://<host>:<port>/ tests reachability from Kong’s own network.
  5. docker logs --tail 50 kong often names the cause, for example connection refused or DNS failure.
  6. 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.

Leave a Reply

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