We want to divide the single monolithic API server into multiple federated servers. Anyone should be able to write their own federated API server to expose APIs they want. Cluster admins should be able to expose new APIs at runtime by bringing up new federated servers.
The following are related but are not the goals of this specific proposal:
There will be 2 new components in the cluster:
The reverse proxy is optional. Clients can discover server URLs using the summarized discovery information and contact them directly. Simple clients, can always use the proxy. The same program can provide both discovery summarization and reverse proxy.
/apis
and list the supported resources
at /apis/<groupVersion>/
)We can have a very simple Go program to summarize discovery information from all
servers. Cluster admins will register each federated API server (its baseURL and swagger
spec path) with the proxy. The proxy will summarize the list of all group versions
exposed by all registered API servers with their individual URLs at /apis
.
We can use any standard reverse proxy server like nginx or extend the same Go program that summarizes discovery information to act as reverse proxy for all federated servers.
Cluster admins are also free to use any of the multiple open source API management tools (for example, there is Kong, which is written in lua and there is Tyk, which is written in Go). These API management tools provide a lot more functionality like: rate-limiting, caching, logging, transformations and authentication. In future, we can also use ingress. That will give cluster admins the flexibility to easily swap out the ingress controller by a Go reverse proxy, nginx, haproxy or any other solution they might want.
Each API server is responsible for storing their resources. They can have their own etcd or can use kubernetes server's etcd using third party resources.
Kubernetes server's /api/v1/componentstatuses
will continue to report status
of master components that it depends on (scheduler and various controllers).
Since clients have access to server URLs, they can use that to do
health check of individual servers.
In future, if a global health check is required, we can expose a health check
endpoint in the proxy that will report the status of all federated api servers
in the cluster.
Since the actual server which serves client's request can be opaque to the client, all API servers need to have homogeneous authentication and authorisation mechanisms. All API servers will handle authn and authz for their resources themselves. In future, we can also have the proxy do the auth and then have apiservers trust it (via client certs) to report the actual user in an X-something header.
For now, we will trust system admins to configure homogeneous auth on all servers. Future proposals will refine how auth is managed across the cluster.
kubectl will talk to the discovery endpoint (or proxy) and use the discovery API to figure out the operations and resources supported in the cluster. Today, it uses RESTMapper to determine that. We will update kubectl code to populate RESTMapper using the discovery API so that we can add and remove resources at runtime. We will also need to make kubectl truly generic. Right now, a lot of operations (like get, describe) are hardcoded in the binary for all resources. A future proposal will provide details on moving those operations to server.
Note that it is possible for kubectl to talk to individual servers directly in which case proxy will not be required at all, but this requires a bit more logic in kubectl. We can do this in future, if desired.
Now that we have resources spread across multiple API servers, we need to be careful to ensure that global policies (limit ranges, resource quotas, etc) are enforced. Future proposals will improve how this is done across the cluster.
When a namespaced resource is created in any of the federated server, that server first needs to check with the kubernetes server that:
To prevent race conditions, the kubernetes server might need to expose an atomic API for all these operations.
While deleting a namespace, kubernetes server needs to ensure that resources in that namespace maintained by other servers are deleted as well. We can do this using resource finalizers. Each server will add themselves in the set of finalizers before they create a resource in the corresponding namespace and delete all their resources in that namespace, whenever it is to be deleted (kubernetes API server already has this code, we will refactor it into a library to enable reuse).
Future proposal will talk about this in more detail and provide a better mechanism.
kubernetes server maintains resource quotas and limit ranges for all resources. Federated servers will need to check with the kubernetes server before creating any resource.
This proposal is not enough for hosted cluster users, but allows us to improve that in the future. On a hosted kubernetes cluster, for eg on GKE - where Google manages the kubernetes API server, users will have to bring up and maintain the proxy and federated servers themselves. Other system components like the various controllers, will not be aware of the proxy and will only talk to the kubernetes API server.
One possible solution to fix this is to update kubernetes API server to detect when there are federated servers in the cluster and then change its advertise address to the IP address of the proxy. Future proposal will talk about this in more detail.
There were other alternatives that we had discussed.