How kgateway-dev/kgateway works
kgateway is a Kubernetes Gateway API control plane that configures Envoy. Users declare Gateways, routes, backends, and policies; controllers reconcile them, query and translate configuration, and synchronize xDS resources to connected Envoy proxies. The repository also contains backend discovery and policy extensions, status reporting, certificate delivery, and control-plane diagnostics. The graph follows documented capabilities and the supplied source index; some subsystem links are omitted where the excerpts do not show their runtime wiring.
Main entry points: model.go Gateway IR · gw_controller.go Gateway reconciler · backend_types.go Gateway API resources · perclient.go xDS synchronization
Components 23
Kubernetes Reconciliation
- Gateway API resources
api/v1alpha1/kgateway/backend_types.go - Gateway reconciler
pkg/kgateway/controller/gw_controller.go - Controller setup
pkg/kgateway/controller/controller.go - Kubernetes collections
pkg/krtcollections - Proxy deployment
pkg/kgateway/deployer/deployer_factory.go
Configuration Translation
- Route and backend queries
pkg/kgateway/query/query.go - Route translation
pkg/kgateway/translator/httproute/gateway_http_route_translator.go - IR translation
pkg/kgateway/translator/irtranslator - Gateway IR
pkg/pluginsdk/ir/model.go
Envoy Runtime
- xDS synchronization
pkg/kgateway/proxy_syncer/perclient.go - Envoy proxy
- Secret discovery
pkg/sds/server/server.go - OAuth secret bootstrap
pkg/kgateway/bootstrap/controller.go - Envoy initialization
pkg/envoyinit/run.go
Gateway Capabilities
- Traffic policies
pkg/kgateway/extensions2/plugins/trafficpolicy/traffic_policy_plugin.go - Backend discovery
pkg/kgateway/extensions2/plugins/backend/plugin.go - Service entries
pkg/kgateway/extensions2/plugins/serviceentry/plugin.go - OAuth policy types
api/v1alpha1/kgateway/oauth2.go - Rust HTTP filters
internal/envoy_modules/filters/rustformation/src/lib.rs
Status and Operations
- Status reporting
pkg/reports/status.go - Admin diagnostics
pkg/kgateway/admin/server.go - Configuration validation
pkg/validator/validator.go
Other components
- Kubernetes user
Connections 22
- Kubernetes user → Gateway API resources: declares
README.md - Gateway API resources → Gateway reconciler: reconciles
- Controller setup → Gateway reconciler: registers
pkg/kgateway/controller/controller.go - Gateway reconciler → Proxy deployment: requests objects
pkg/kgateway/controller/gw_controller.go - Controller setup → Kubernetes collections: configures
pkg/kgateway/controller/controller.go - Route and backend queries → Kubernetes collections: queries
pkg/kgateway/query/query.go - Route translation → Route and backend queries: resolves routes
- IR translation → Gateway IR: produces
- Traffic policies → Gateway IR: contributes policies
- Backend discovery → Gateway IR: contributes backends
- Service entries → Gateway IR: contributes endpoints
- Proxy deployment → Envoy proxy: deploys proxies
- xDS synchronization → Gateway IR: reads IR
pkg/kgateway/proxy_syncer/perclient.go - xDS synchronization → Envoy proxy: sends xDS
README.md - Envoy proxy → Secret discovery: requests secrets
- OAuth secret bootstrap → Gateway API resources: supports OAuth2
pkg/kgateway/bootstrap/controller.go - Envoy initialization → Envoy proxy: starts Envoy
- Gateway reconciler → Status reporting: reports status
pkg/kgateway/controller/gw_controller.go - Configuration validation → Gateway API resources: validates
- OAuth policy types → Traffic policies: configures OAuth2
- Rust HTTP filters → Envoy proxy: extends filters
- Admin diagnostics → xDS synchronization: exposes snapshots