A production ready Kubernetes admission webhook making sure resources are sized correctly using Kubewebhook.
The webhook is based on the production ready Kubewebhook example and comes with:
- Clean and decouple structure.
- Metrics.
- Gracefull shutdown.
- Testing webhooks.
- Serve multiple webhooks on the same application.
The application is mainly structured in 3 parts:
main
: This is where everything is created, wired, configured and set up, cmd/k8s-sizing-webhook.http
: This is the package that configures the HTTP server, wires the routes and the webhook handlers. internal/http/webhook.- Application services: These services have the domain logic of the validators and mutators:
mutation/mem
: Logic formemfix.bitteeinbit.dev
webhook.mutation/cpu
: Logic forremove-cpu-limit.bitteeinbit.dev
webhook. (TODO)
You can use the example YAML deploy
folder to deploy it.
- Webhook type: Mutating.
- Resources affected:
deployments
,daemonsets
,cronjobs
,jobs
,statefulsets
,pods
This webhooks makes the memory guaranteed. This way OOM can be reduced because memory balloning is avoided.
- If both requests and limits are provided, the limit is also used for requests.
- If only requests is set, then limit is set to requests' value.
- If no value is provided, then the resource is left alone.