This repository has the implementation of the admission controller's mutating webhook from scratch.
This example mutating webhook adds the label example-webhook: "it-worked"
on every new pod that has a label example-webhook-enabled: "true"
.
-
Clone the repository and navigate into the folder
git clone https://github.com/AxiomSamarth/k8s-mutating-webhook cd k8s-mutating-webhook
-
Apply all the manifests on to your K8s cluster
kubectl create -f ./manifests/
-
The new pod created out of the
manifests/demo-pod.yaml
would have an additional label in themetadata
asexample-webhook: "it-worked"
If this has appeared then everything has worked well.
Feel free to raise issues and PRs if you see any scope to improve this example repository for wider consumption. Happy helming!