If the controller generates configuration that it cannot apply to Kong successfully, reviewing the generated configuration manually and/or applying it in a test environment can help locate potential causes.
Under normal operation, the controller doesn’t store generated configuration; it is only sent to Kong’s Admin API. The --dump-config
flag enables a diagnostic mode where the controller also saves generated configuration and Kong Gateway responses to memory. You can retrieve these via the web interface of the diagnostic server at host:10256/debug/config
.
To use the diagnostic mode:
-
Set the --dump-config
flag (or CONTROLLER_DUMP_CONFIG
environment variable) to true
. Optionally set the --dump-sensitive-config
flag to true
to include un-redacted TLS certificate keys and credentials.
If you’re deploying with the Helm chart, add the following to your values.yaml
file under the controller
key:
ingressController:
env:
dump_config: "true"
dump_sensitive_config: "true"
To enable configuration dumping temporarily for an existing deployment, run the following command:
kubectl set env -n kong deployment/kong-controller \
CONTROLLER_DUMP_CONFIG="true" \
CONTROLLER_DUMP_SENSITIVE_CONFIG="true" \
-c ingress-controller
-
(Optional) Make a change to a Kubernetes resource that you know will reproduce the issue. If you are unsure what change caused the issue originally, you can omit this step.
-
Port forward to the diagnostic server:
kubectl port-forward -n kong deployments/kong-controller 10256:10256
-
Retrieve successfully, or unsuccessfully, applied configurations:
curl -s localhost:10256/debug/config/successful | jq .config > last_good.json
curl -s localhost:10256/debug/config/failed | jq .config > last_bad.json
-
v3.4+ Retrieve the last error response body received from Kong Gateway:
curl -so raw_error_body.json localhost:10256/debug/config/raw-error
Once you have dumped configuration, take one of the following approaches to isolate issues:
-
If you know of a specific Kubernetes resource change that reproduces the issue, diffing last_good.json
and last_bad.json
will show the change the controller is trying to apply unsuccessfully.
diff -u last_good.json last_bad.json
-
You can apply dumped configuration via the /config
Admin API endpoint (DB-less mode) or using decK (DB-backed mode) to a test instance not managed by the ingress controller. This approach lets you review requests and responses (passing --verbose 2
to decK will show all requests).
-
To run a DB-less Kong Gateway instance with Docker for testing purposes, run curl https://get.konghq.com/quickstart | bash -s -- -D
.
Once this image is running, run curl http://localhost:8001/config --json @last_bad.json
to try applying the configuration and see any errors.
You can also analyze the returned error response body from Kong Gateway to understand the issue.