Introduction to dynamic admission controllers
There are two ways to extend Kubernetes:
- Build a custom resource definition so that you can define your own objects and APIs.
- Implement a webhook that listens for requests from the API server and responds with the necessary information. You may recall that in Chapter 7, Integrating Authentication into Your Cluster, we explained that a custom webhook was used to validate tokens.
Starting in Kubernetes 1.9, a webhook can be defined as a dynamic admission controller, and in 1.16, the dynamic admission controller API became Generally Available (GA).
The protocol is very straightforward. Once a dynamic admission controller is registered for a specific object type, the webhook is called with an HTTP post every time an object of that type is created or edited. The webhook is then expected to return JSON that represents whether it is allowed or not.
Important note
As of 1.16, admission.k8s.io/v1
is at GA. All examples...