Kubernetes API Aggregation Layer: Extending the API Server

The API Aggregation Layer bolts custom API servers onto the main Kubernetes API, with kube-apiserver acting as a proxy. This powers features like the metrics server (kubectl top) and enables complex extensions.
Why it exists
Kubernetes needed a way to add significant, non-core API functionality without bloating the main kube-apiserver. It allows new features, like metrics or service brokers, to be developed and deployed independently while still being accessible through the standard Kubernetes API machinery and kubectl.
The mental model
Think of the main kube-apiserver as a reverse proxy with a default backend (itself) and configurable routes. The Aggregation Layer lets you add new routing rules. When a request comes in for /apis/myextension.example.com/v1/..., the API server checks its registrations, sees your custom server owns that path, and proxies the request to it. To the client, it's a seamless part of the Kubernetes API.
How it works
You create a Kubernetes APIService object. This object tells the main API server about your custom API, including its group and version (like metrics.k8s.io/v1beta1), and how to connect to the Service that runs your custom API server pod. The kube-apiserver then proxies requests matching that group/version to your service. Your custom API server must implement the Kubernetes API conventions to integrate properly.
When to use it
Use it when you need to add new API functionality that goes beyond simple data storage. This is the right choice if you need to implement custom verbs (beyond CRUD), have validation logic that is too complex for a CRD validation webhook, or need to connect to a separate backing storage system. The official metrics-server is the classic example.
When not to use it
Do not use the aggregation layer if all you need is to define a new resource type with standard create, read, update, and delete (CRUD) operations. A Custom Resource Definition (CRD) is a much simpler, more robust, and more common solution for that use case. CRDs are managed directly by the kube-apiserver, avoiding the operational overhead of running your own API server.
One canonical example
The Metrics Server. It registers the metrics.k8s.io API group. When you run kubectl top pods, kubectl sends a request to the main API server for a resource under that API group. The API server, via the aggregation layer, proxies this request to the Metrics Server pods. The Metrics Server collects data from kubelets and returns the resource usage, which kubectl then displays. The core API server knows nothing about metrics itself.
Interview question
Which scenario most strongly indicates that Kubernetes API Aggregation is a more suitable solution than a Custom Resource Definition (CRD)?
- a.Implementing an API that needs custom verbs or complex validation logic beyond what CRD validation webhooks offer.Correct
- b.Storing custom resource data directly within the main Kubernetes etcd cluster for simplicity.
- c.Minimizing the operational overhead associated with introducing new API functionality.
- d.Defining a new resource type that requires standard Create, Read, Update, and Delete (CRUD) operations.
Why? this is the answer
API Aggregation is designed for scenarios requiring custom verbs, complex validation logic, or separate backing storage, which go beyond the capabilities of CRDs. For simple CRUD operations, CRDs are explicitly recommended as a simpler and more robust solution, and they also minimize operational overhead compared to running a separate aggregated API server.
Just read this? Test yourself on what you have been reading.
Read the original → kubernetes.io
- #kubernetes
- #api
- #architecture
- #advanced
Put your scrolling time to good use
Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on kubernetes — each one lists the topics its interview covers.
See open roles