Example Mutating Admission Controller Webhook
Kind used as Kubernetes cluster
- Create signed cert/key pair (use script from https://github.com/morvencao/kube-mutating-webhook-tutorial)
git clone https://github.com/morvencao/kube-mutating-webhook-tutorial
./kube-mutating-webhook-tutorial/deployment/webhook-create-signed-cert.sh --service mutate-webhook-svc --namespace default --secret mutate-webhook-secret
export CA_BUNDLE=$(kubectl get secrets -o jsonpath="{.items[?(@.metadata.annotations['kubernetes\.io/service-account\.name']=='default')].data.ca\.crt}")
cat ./mutate_admission.yaml | ./kube-mutating-webhook-tutorial/deployment/webhook-patch-ca-bundle.sh > ./mutate_admission_ca.yaml
- Create image
docker build . -t mutate
- Push image
kind load docker-image mutate
- Create mutating webhook
kubectl apply -f webhook.yaml
- Create Mutating Webhook Configuration
kubectl apply -f mutate_admission_ca.yaml
- Mutate busbox
kubectl apply -f box.yaml