Federated APIOps with Kong · Part 1. The design. The code is in kong-federated-apiops.

Federated APIOps is a way for many API teams to share one API gateway. A platform team runs Kong Gateway Enterprise and owns what every API must have (in this series a request ID, a size limit and a rate limit) and who may change what. Each API team owns its own APIs and ships them through a pipeline, starting from its OpenAPI spec, without a ticket to the platform team. Teams move at their own pace; the platform keeps the guardrails.

Federated sits between two other ways of running APIs. Centralised: the platform team builds and runs every API, and becomes the queue. Decentralised: every team runs its own gateway, and standards drift apart. This series builds the shared-gateway variant of federated: one Kong Gateway Enterprise, one workspace per team. The heavier variant gives each team its own control plane or its own data planes.

A team adds rate-limiting to its own service and, for that traffic, the platform’s limit is gone. No error. That’s the problem with sharing one Kong Gateway Enterprise between API teams. The platform teams I work with want mandatory plugins teams can’t touch, teams that deploy from their OpenAPI spec, no team in another’s workspace, and a repository layout that scales.

This part is the design. Part 2 builds it and tries to break it. Part 3 adds Kong Manager sign-in with Keycloak.

At a glance

  • You get: mandatory plugins teams can’t edit or delete (403), overrides stopped by lint and caught by a drift check every weekday, and workspaces teams can’t cross (403).
  • The split: Terraform for the platform, decK for teams, deck file lint rulesets in between.
  • The setting it rests on: enforce_rbac = both in kong.conf, so Kong checks which Admin API paths a token may call (endpoint RBAC) and which entities it may touch (entity-level RBAC).
  • You need: Kong Gateway Enterprise, because workspaces and RBAC are Enterprise features.

The model

PlatformAPI team
Workspaces, roles, pipeline RBAC usersowns (Terraform)none
Mandatory pluginsownsedit or delete: 403
Central rulesetsownspasses them
Services, routes, own plugins, own rulesetssets the rules, doesn’t review each changeowns, through its pipeline token (decK)
Kong Managerbreak-glass super adminread-only (workspace-read-only), assigned by your IdP

Changes go through pipelines only. Each team’s pipeline has its own RBAC user with an Admin API token scoped to the team’s workspace, and the team’s people get a read-only view in Kong Manager (Part 3 signs them in with Keycloak). Terraform’s kong-gateway provider manages workspaces, RBAC users and their permissions. Teams use decK because it starts from the OpenAPI spec they already have, with openapi2kong.

Kong Manager listing the default, orders and payments workspaces
One workspace per team, created by Terraform.

Kong can’t lock a plugin, so four layers do it

decK with a tag per team “ignores any resources that don’t have that tag”, which is how Kong’s federated configuration guide splits teams. That keeps honest pipelines apart, but it isn’t a boundary. With one admin token in CI, only the tags keep teams apart.

Kong Manager plugins of the payments workspace: three global plugins tagged platform and two service plugins tagged team-payments
Payments: the platform's three plugins and the team's two, told apart by tag.

A plugin on a service or route takes precedence over the same plugin configured globally, for that plugin name only. And endpoint RBAC can’t tell the platform’s plugins from a team’s, because decK writes both to /plugins. No single setting protects a mandatory plugin.

  1. Lint in the pipeline. The allowed plugin list leaves out the mandatory names, so a team’s pipeline can’t ship an override, a global plugin or ordering.
  2. Endpoint RBAC keeps each team’s pipeline token in its own workspace.
  3. Entity-level RBAC denies changes to each mandatory plugin’s ID, with 403.
  4. Drift, every weekday. A token used outside the pipeline can still create its own same-name plugin, because RBAC can’t block a new one, and the drift workflow fails on it.

Lint can’t stop a direct Admin API call and RBAC can’t stop a new plugin, so you need both. Kong’s APIOps example merges the global plugins into each team’s file, which works with one trusted pipeline but here would let a team’s token sync the platform’s plugins.

Decision 1: a workspace per team

Workspace per teamShared workspace, tag per team
IsolationRBAC on the Admin APIthe pipeline only
Mandatory pluginsone copy per workspaceone copy

I’d use a workspace per team from the second team on. A global plugin “runs on every request, but only within its own Workspace”, so Terraform creates the mandatory plugins per workspace with one for_each.

Decision 2: a repository per team

One repositoryOne per team
Who mergesCODEOWNERS per team folderthe team
Central ruleschecked against every team by CI on each changeapply when the team bumps the platform version
Who controls the pipelinethe platformthe team, so keep its prod token with the platform

In a federated model I’d give each team its own repository, calling the platform’s reusable workflow at a pinned version. The companion repository keeps every team in one place on purpose, so a single clone runs the whole model; teams/<team>/ is what a team’s repository would hold. Its guide shows how to split a team out. No repository per environment: the same files go to dev and prod, and environments/<env>.yaml holds the few values that differ.

Two tiers of rulesets

deck file lint checks both the spec and the decK file built from it (a worked ruleset).

What to know about entity-level RBAC

  • Bootstrap first. Kong’s 2.8 RBAC guide says entity permissions “must be bootstrapped before enforcement is enabled”; I found no current page on it. On 3.16 I skipped that step, and the super admin then listed none of the entities team pipelines had created.
  • Ownership follows the creating RBAC user. The provider replaces the user when its token changes (user_token: “Requires replacement”). With ownership alone, the new user saw none of the team’s services and the next deploy failed with 409 UNIQUE violation. A wildcard entity permission on the team’s role keeps access across rotations.
  • No permission reads as 403, not 404. That includes a plugin someone deleted, so Terraform running as an identity without that wildcard can’t tell it’s gone. Run the platform pipeline as its own RBAC user with it.

When this is too much

One team on one gateway needs one workspace, a decK pipeline and the rulesets. On Konnect, workspaces “are supported on hybrid and Dedicated Cloud control planes” and Konnect has its own roles; this series is about self-managed Gateway Enterprise.

Next: Part 2 builds all of it and tries every forbidden change.

References