Two interaction models. The Admin API (
:8001) is imperative: changes take effect immediately but are lost on DB-less mode restarts. deck is declarative: the correct model for production where config lives in Git and is applied via CI/CD. Use the Admin API for inspection and emergency changes; use deck for everything that should persist. DB-less mode uses declarative_config YAML: deck targets DB-backed Kong.
cross-cutting: know these before anything else
Admin API base patterns
curl -s http://localhost:8001/ | jq '{version:.version,node_id:.node_id}'
curl -s http://localhost:8001/status | jq
# Admin API port: 8001 (HTTP) / 8444 (HTTPS)
# Proxy port: 8000 (HTTP) / 8443 (HTTPS)
# Set KONG_ADMIN=http://localhost:8001 in shell
deck workflow (config-as-code)
deck dump > kong.yaml
deck validate kong.yaml
deck diff --state kong.yaml
deck sync --state kong.yaml
# deck ping: verify connectivity
deck ping
pagination + filtering
curl -s "http://localhost:8001/services?size=100" | jq '.data[].name'
curl -s "http://localhost:8001/services?size=100&offset=tags: the targeting mechanism
curl -s "http://localhost:8001/services?tags=env:prod" | jq '.data[].name'
curl -s "http://localhost:8001/plugins?tags=team:platform" | jq
# tags are on every entity: services, routes, plugins, upstreams
# deck supports --select-tag to scope sync to a subset
deck sync --select-tag env:prod --state kong.yaml
green = shell command
blue = Admin API response / JSON path
yellow = deck YAML / config snippet
| Concept / Command | Phase | Key commands | Use case |
|---|---|---|---|
| connectivity check | connect |
curl -s http://localhost:8001/ | jq '{version:.version,node_id:.node_id,lua_version:.lua_version}'
curl -s http://localhost:8001/status | jq '{server:.server,memory:.memory.lua.http_allocated_gc}'
deck ping --kong-addr http://localhost:8001
# Kong Manager UI: :8002 (HTTP) / :8445 (HTTPS)
# Kong Admin API auth (Enterprise): set KONG_ADMIN_TOKEN
curl -s -H "Kong-Admin-Token: $KONG_ADMIN_TOKEN" http://localhost:8001/services | jq
|
First commands after deployment or post-incident. status shows server stats and memory usage: memory pressure is a common Kong stability issue. deck ping validates that deck can reach the Admin API before attempting a sync. Enterprise Kong requires Kong-Admin-Token header on all Admin API calls. |
| service list / inspect | services |
curl -s http://localhost:8001/services | jq '.data[] | {name,host,port,protocol,path}'
curl -s http://localhost:8001/services/my-service | jq
curl -s http://localhost:8001/services/my-service/routes | jq '.data[].paths'
curl -s http://localhost:8001/services/my-service/plugins | jq '.data[].name'
curl -s "http://localhost:8001/services?size=100" | jq '[.data[] | {name,enabled:.enabled}]'
|
A Kong Service maps to an upstream API. Listing services gives the inventory of what Kong is proxying: inspect host and port to confirm the backend address. Services can be disabled without deleting them. Fetching a service's routes and plugins in separate calls is the correct pattern for understanding full configuration. |
| service create / update | services |
curl -s -X POST http://localhost:8001/services \
-d name=my-service \
-d url=http://backend:8080 \
-d tags=env:prod | jq '{id,name,host,port}'
curl -s -X PATCH http://localhost:8001/services/my-service \
-d host=new-backend \
-d port=9090 | jq '{name,host,port}'
curl -s -X PUT http://localhost:8001/services/my-service \
-d url=http://backend:8080 \
-d connect_timeout=5000 \
-d write_timeout=10000 \
-d read_timeout=10000 | jq
|
Use PATCH for partial updates; PUT replaces the entire entity. Timeouts are in milliseconds: defaults (60s) are often too high for production APIs where you'd rather fail fast. url shorthand expands to host/port/path/protocol. In production, prefer deck YAML over direct Admin API mutations. |
| route list / inspect | routes |
curl -s http://localhost:8001/routes | jq '.data[] | {name,paths,methods,hosts,service:.service.id}'
curl -s http://localhost:8001/routes/my-route | jq
curl -s "http://localhost:8001/services/my-service/routes" | jq '.data[] | {name,paths,strip_path,preserve_host}'
|
strip_path and preserve_host are the two most commonly misconfigured route fields. strip_path=true removes the matched path prefix before forwarding: if your backend doesn't have /api/v1 in its routes, you want this. preserve_host=false sends the upstream's hostname, not the client's Host header. |
| route create / update | routes |
curl -s -X POST http://localhost:8001/services/my-service/routes \
-d name=my-route \
-d "paths[]=/api/v1" \
-d "methods[]=GET" \
-d "methods[]=POST" \
-d strip_path=true | jq '{id,name,paths,methods}'
curl -s -X PATCH http://localhost:8001/routes/my-route \
-d "paths[]=/api/v2" | jq '.paths'
curl -s -X DELETE http://localhost:8001/routes/my-route
|
Array fields (paths, methods, hosts) use the field[] form-encoding syntax: common source of curl mistakes. Delete is immediate and permanent: no soft delete. Routes can match on paths, hosts, methods, headers, or SNI in any combination. More specific routes (more matching criteria) take priority. |
| plugin list / inspect | plugins |
curl -s http://localhost:8001/plugins | jq '.data[] | {name,service:.service.id,route:.route.id,enabled,config}'
curl -s http://localhost:8001/plugins/enabled | jq '.enabled_plugins[]'
curl -s http://localhost:8001/plugins/schema/rate-limiting | jq '.fields[] | keys[]'
curl -s http://localhost:8001/services/my-service/plugins | jq '.data[] | {name,enabled,config}'
|
/plugins/enabled lists every plugin available on this Kong instance. Check before configuring a plugin that might not be installed. /plugins/schema/<name> reveals all valid config fields: avoids trial and error. Plugins have scope: global, service-level, route-level, or consumer-level. |
| rate-limiting plugin | plugins |
curl -s -X POST http://localhost:8001/services/my-service/plugins \
-d name=rate-limiting \
-d config.minute=100 \
-d config.hour=1000 \
-d config.policy=redis \
-d config.redis_host=redis \
-d config.redis_port=6379 | jq '{id,name,config}'
deck YAML equivalent:
plugins:
- name: rate-limiting
service: my-service
config: {minute: 100, hour: 1000, policy: redis}
|
Use policy=redis in production: the default local policy counts per Kong node, not globally, so limits are multiplied by node count. Redis policy requires a shared Redis instance but enforces accurate global rate limits across a Kong cluster. Set both per-minute and per-hour limits to catch burst and sustained abuse. |
| auth plugins | plugins |
# JWT plugin:
curl -s -X POST http://localhost:8001/services/my-service/plugins \
-d name=jwt \
-d config.claims_to_verify=exp | jq '{id,name}'
# Key Auth plugin (API keys):
curl -s -X POST http://localhost:8001/routes/my-route/plugins \
-d name=key-auth \
-d config.key_names=X-API-Key | jq '{id,name}'
# OAuth2:
curl -s -X POST http://localhost:8001/services/my-service/plugins \
-d name=oauth2 \
-d config.scopes[]=read \
-d config.scopes[]=write \
-d config.mandatory_scope=true | jq
|
Auth plugins are applied at service or route level: service level protects all routes, route level allows mixed auth on a single service. JWT plugin validates signature and claims but doesn't issue tokens. Key Auth requires creating consumers and credentials. OAuth2 plugin manages token issuance. It's a full OAuth2 server embedded in Kong. |
| proxy-cache + request-transformer | plugins |
curl -s -X POST http://localhost:8001/services/my-service/plugins \
-d name=proxy-cache \
-d config.response_code=200 \
-d config.request_method=GET \
-d config.content_type=application/json \
-d config.cache_ttl=300 \
-d config.strategy=memory | jq '{id,name}'
curl -s -X POST http://localhost:8001/routes/my-route/plugins \
-d name=request-transformer \
-d "config.add.headers[]=X-Internal-Source:kong" \
-d "config.remove.headers[]=X-Forwarded-For" | jq
|
Proxy cache with strategy=memory is per-node. Use Redis strategy for cluster-wide caching. Cache only GET responses with explicit content types to avoid caching errors or partial responses. Request transformer is the correct place to inject internal headers (correlation IDs, routing hints) rather than modifying upstream code. |
| upstreams + targets | upstreams |
curl -s http://localhost:8001/upstreams | jq '.data[] | {name,algorithm,healthchecks:.healthchecks.active.healthy}'
curl -s http://localhost:8001/upstreams/my-upstream/targets | jq '.data[] | {target,weight,health}'
curl -s http://localhost:8001/upstreams/my-upstream/health | jq '.data[] | {target,health:.health}'
curl -s -X POST http://localhost:8001/upstreams \
-d name=my-upstream \
-d algorithm=round-robin \
-d healthchecks.active.healthy.interval=10 \
-d healthchecks.active.unhealthy.http_failures=3 | jq
|
Upstreams provide load balancing and health checking for service backends. /upstreams/my-upstream/health is the definitive check for why traffic isn't reaching a target: shows HEALTHY, UNHEALTHY, or UNDEFINED per target. Algorithms: round-robin, least-connections, consistent-hashing (sticky sessions by header/cookie). |
| target management | upstreams |
curl -s -X POST http://localhost:8001/upstreams/my-upstream/targets \
-d target=10.0.0.1:8080 \
-d weight=100 | jq '{id,target,weight}'
curl -s -X POST http://localhost:8001/upstreams/my-upstream/targets \
-d target=10.0.0.2:8080 \
-d weight=0 | jq '{target,weight}'
# weight=0 drains a target without removing it
curl -s -X DELETE http://localhost:8001/upstreams/my-upstream/targets/<target-id>
curl -s -X POST http://localhost:8001/upstreams/my-upstream/targets/<target-id>/unhealthy
|
Setting weight=0 drains a target gracefully: in-flight requests complete, new requests go elsewhere. This is the correct way to remove a backend during deployment. Manually marking a target unhealthy (/unhealthy endpoint) forces Kong to stop routing to it immediately. Use during emergency maintenance. |
| deck core workflow | deck |
deck ping
deck dump --output-file kong.yaml
deck validate --state kong.yaml
deck diff --state kong.yaml
deck sync --state kong.yaml
deck sync --state kong.yaml --dry-run
deck reset --force
|
diff before sync: always. Diff shows exactly what will be created, updated, or deleted. reset --force wipes all Kong config. Use only in dev/test. In CI: validate on PR, diff as PR comment, sync on merge to main. Never sync untested YAML to production without a diff review. |
| deck file operations | deck |
deck file merge --state services.yaml --state plugins.yaml > kong.yaml
deck file lint --state kong.yaml
deck file render --state kong.yaml
deck sync --select-tag env:prod --state kong.yaml
deck dump --select-tag env:prod --output-file prod.yaml
# --select-tag scopes sync to tagged entities only (safe partial update)
|
--select-tag is the production safety mechanism: scope a sync to only the entities tagged for a specific team or environment, leaving others untouched. file merge lets you maintain services and plugins in separate YAML files and merge at sync time. file render resolves templating and shows the final config that would be synced. |
| deck in CI/CD | deck |
# GitHub Actions step pattern:
- uses: kong/setup-deck@v1
with: { version: "1.40.0" }
- run: deck validate --state kong.yaml
- run: deck diff --state kong.yaml
env: { DECK_KONG_ADDR: "${{ secrets.KONG_ADMIN_URL }}" }
- run: deck sync --state kong.yaml
if: github.ref == 'refs/heads/main'
|
Gate sync on branch: diff runs on every PR, sync only on merge to main. Store the Kong Admin URL and token as GitHub secrets. Pin the deck version explicitly: deck minor versions occasionally have breaking flag changes. The kong/setup-deck action handles installation cleanly. |
| consumer management | inspect |
curl -s http://localhost:8001/consumers | jq '.data[] | {username,custom_id,tags}'
curl -s http://localhost:8001/consumers/my-consumer/key-auth | jq '.data[].key'
curl -s http://localhost:8001/consumers/my-consumer/jwt | jq '.data[] | {key,algorithm}'
curl -s -X POST http://localhost:8001/consumers \
-d username=my-app \
-d custom_id=app-123 | jq
curl -s -X POST http://localhost:8001/consumers/my-consumer/key-auth | jq '.key'
|
Consumers are Kong's identity model. They map to API clients, not end users. Credentials (API keys, JWTs) are attached to consumers. Listing a consumer's credentials reveals all active keys: useful for auditing or rotating. custom_id links Kong consumers to your application's user/tenant identifiers. |
| traffic debugging | inspect |
curl -sv http://localhost:8000/api/v1/health -H "Host: api.example.com" 2>&1 | grep -E "< HTTP|< X-Kong"
curl -s http://localhost:8001/debug/node/log_level | jq
curl -s -X PUT http://localhost:8001/debug/node/log_level/debug
curl -s -X PUT http://localhost:8001/debug/node/log_level/notice
# Kong response headers reveal routing:
# X-Kong-Proxy-Latency: time Kong spent routing (ms)
# X-Kong-Upstream-Latency: time the backend took (ms)
# X-Kong-Upstream-Status: what the backend returned
|
X-Kong-Proxy-Latency vs X-Kong-Upstream-Latency immediately separates Kong overhead from backend latency: if proxy latency is high, the issue is Kong plugins or routing; if upstream latency is high, the issue is your backend. Temporarily enabling debug log level on a specific node is safe in production. It only affects that node and is reset on restart. |
| node info + cluster | inspect |
curl -s http://localhost:8001/clustering/data-planes | jq '.data[] | {id,ip,version,status,last_seen}'
curl -s http://localhost:8001/debug/profiling/start
curl -s http://localhost:8001/debug/profiling/stop
curl -s http://localhost:8001/endpoints | jq '.data | length'
curl -s http://localhost:8001/timers | jq
|
/clustering/data-planes lists all connected data planes in a control plane / data plane (hybrid mode) deployment: last_seen reveals data planes that have stopped syncing. /timers shows background timer activity: excessive timer count can indicate runaway plugin behavior. /endpoints count confirms all Admin API routes are registered. |
No entries match this filter.