This repo was forked from k-mitevski/kubernetes-validating-webhook. I suggest this great article for a newcomer on webhooks to get basic but valuable insight about writing a simple admission webhook.
Even though we can limit the requested cpu using the limitrange on the container level, I just wanted to do the same thing using the webhook.
When a deployment is triggered, the request is intercepted by the webhook and forwarded to the backend. The backend checks the CPU requests of each container of the deployment. To approve the deployment request, the requested CPU values should be less than the threshold value which is given from the environment value of the webhook container.
env:
- name: cpu
value: "2"
Threshold value can be given as core or milicores.
env:
- name: cpu
value: "2500m"
Namespaces where our control logic is intended to be executed can be manipulated from the configmap.
data:
properties.yaml: |
default
devteam