Skip to main content
Version: Next

Configuration Reference

Kono uses a single declarative YAML configuration file.

info

Only YAML is supported. JSON and TOML are not supported to reduce complexity and avoid inconsistencies.

Root


schema: v1
debug: false
FieldTypeRequiredDescription
schemastringMust be v1
debugboolEnables debug logging. Adds verbose output across router, dispatcher, and upstream components

Server


gateway:
server:
port: 7805
timeout: 20s
pprof:
enabled: true
port: 6060
metrics:
enabled: true
provider: prometheus
FieldTypeDefaultDescription
portintHTTP port the gateway listens on
timeoutduration5sRead and write timeout for incoming requests
pprof.enabledboolfalseEnable pprof profiling server (localhost only)
pprof.portint6060Port for the pprof server
metrics.enabledboolfalseEnable /metrics endpoint
metrics.providerstringMetrics provider. Currently supports prometheus

Routing


gateway:
routing:
trusted_proxies:
- 127.0.0.1/32
- 10.0.0.0/8
rate_limiter:
enabled: true
config:
limit: 100
window: 1s
flows:
- ...
FieldTypeDescription
trusted_proxieslist[CIDR]IP ranges whose X-Forwarded-* headers are trusted. Untrusted proxy headers are ignored and rewritten
rate_limiter.enabledboolEnable per-IP rate limiting
rate_limiter.configmapRate limiter configuration (limit, window)

Flows


A flow defines how an incoming request is matched, processed, and dispatched to upstreams.

flows:
- path: /api/v1/users/{user_id}
method: GET
aggregation:
strategy: merge
best_effort: true
on_conflict:
policy: prefer
prefer_upstream: users
max_parallel_upstreams: 10
plugins:
- ...
middlewares:
- ...
scripts:
- ...
upstreams:
- ...
FieldTypeRequiredDescription
pathstringURL path to match. Supports {param} path parameters
methodstringHTTP method: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS
aggregation.strategystringHow to combine upstream responses: merge, array, or namespace
aggregation.best_effortboolIf true, return partial results when some upstreams fail (HTTP 206 Partial Content)
aggregation.on_conflict.policystringConflict resolution for merge strategy: overwrite, first, error, prefer
aggregation.on_conflict.prefer_upstreamstringName of the upstream to prefer when policy: prefer
max_parallel_upstreamsintMax concurrent upstream calls for this flow. Defaults to 2 * NumCPU

Aggregation Strategies


StrategyDescription
mergeMerges JSON objects from all upstreams into one. Conflict policy controls key collisions
arrayWraps all upstream responses in a JSON array
namespacePlaces each upstream response under its name as a key: {"users": {...}, "orders": {...}}

Conflict Policies (merge only)


PolicyDescription
overwriteLater upstream overwrites earlier value on key collision
firstFirst upstream's value is kept on key collision
errorReturn 409 Conflict on any key collision
preferValue from prefer_upstream is always used on collision

Upstreams


upstreams:
- name: users
hosts:
- http://user-service-1.local
- http://user-service-2.local
path: /v1/users/{user_id}
method: GET
timeout: 3s
forward_queries: ["*"]
forward_headers: ["X-*"]
forward_params: ["tenant_id"]
policy:
...
FieldTypeDefaultDescription
namestringauto-generatedUpstream identifier used in logs, metrics, and namespace strategy
hostslist or stringTarget host(s). Multiple hosts enable load balancing
pathstringUpstream path. {param} placeholders are expanded from flow path parameters
methodstringHTTP method override. Falls back to the original request method
timeoutduration3sPer-request timeout including retries
forward_querieslistQuery params to forward. "*" forwards all, or specify exact keys
forward_headerslistHeaders to forward. Supports "*", prefix wildcards "X-*", or exact names
forward_paramslistPath parameters to forward as query string params. "*" forwards all

Upstream Policy


policy:
allowed_statuses: [200, 404]
require_body: true
max_response_body_size: 4096
header_blacklist: ["X-Internal-Token"]
retry:
max_retries: 3
retry_on_statuses: [500, 502, 503]
backoff_delay: 500ms
circuit_breaker:
enabled: true
max_failures: 5
reset_timeout: 2s
load_balancing:
mode: round_robin
FieldTypeDescription
allowed_statuseslist[int]Accepted HTTP status codes. Responses outside this list are treated as policy violations
require_bodyboolFail if upstream response body is empty
max_response_body_sizeintMax response body in bytes. Responses exceeding this are rejected
header_blacklistlist[string]Response headers to strip before passing to the aggregator
retry.max_retriesintMaximum number of retry attempts after the initial request
retry.retry_on_statuseslist[int]HTTP status codes that trigger a retry
retry.backoff_delaydurationFixed delay between retry attempts
circuit_breaker.enabledboolEnable circuit breaker for this upstream
circuit_breaker.max_failuresintConsecutive failures before opening the circuit
circuit_breaker.reset_timeoutdurationTime in open state before transitioning to half-open
load_balancing.modestringround_robin or least_conns. Only applies when multiple hosts are configured
info

The circuit breaker tracks three states: closed (normal), open (rejecting requests), half-open (testing recovery). All three are exposed via the kono_circuit_breaker_state metric.

Plugins


plugins:
- name: snakeify
source: builtin
- name: myplugin
source: file
path: /etc/kono/plugins/
config:
key: value
FieldTypeDescription
namestringPlugin name
sourcestringbuiltin (shipped with Kono) or file (custom .so)
pathstringDirectory containing the .so file. Required when source: file
configmapPlugin-specific configuration passed at initialization

Plugins run in two phases:

  • Request phase — before upstream dispatch. Can modify request context and headers
  • Response phase — after aggregation. Can modify response headers and body
warning

Plugins are loaded as Go shared objects (.so). They must be compiled with the exact same Go version as the gateway binary. Version mismatch causes a panic at startup.

Middlewares


middlewares:
- name: recoverer
source: builtin
- name: logger
source: builtin
config:
enabled: true

Middlewares use the same name, source, path, and config fields as plugins. They wrap the entire flow handler and execute in the order defined — outermost first. Built-in middlewares include recoverer, logger, auth, and compressor.

Lumos Scripts


scripts:
- source: file
path: /etc/kono/scripts/auth.lua

Lua scripts run before upstream dispatch. They communicate with the gateway over a Unix socket using a length-prefixed JSON protocol — no additional network hop compared to a sidecar approach.

A script returns one of two actions:

  • continue — proceed with the (optionally modified) request
  • abort — reject the request with a specified HTTP status

See Lumos for the full scripting reference.