Search code examples
kuberneteswebhookskubernetes-apiserverkube-apiserver

API endpoints for kubernetes mutating webhook server


As described here, this is a reference implementation of a webhook server as used in kubernetes e2e test. In the main function, a number of endpoints have been defined to handle different requests for mutation. However, there is no clear documentation as to which endpoint gets invoked when.

So, how do we know which endpoint is invoked when?


Solution

  • I see you are trying to understand what is the ordering of execution of mutating webhooks.

    I have found this piece of code in kubernetes repo. Based on this you can see that these are sorted by name of a webhook to have a deterministic order.

    A single ordering of mutating admissions plugins (including webhooks) does not work for all cases, so take a look at mutating plugin ordering section in Admission webhook proposal for explanation how its handled.

    Also notice there are no "pod only endpoints" or "endpoints that get called for pods". Let's say you have your webhook server and want to mutate pods and your server has only one endpoint: /. If you want to mutate pods with it you need to specify it under rules. So setting rules[].resources: ["pods"] and rules[].operations: ["CREATE"] in your webhook config will run your mutating webhook whenever there is pod to be created.

    Let me know it it helped.