Skip to content

ninefiveslabs/side_car_mutate

Repository files navigation

Mutate webhook

Example Mutating Admission Controller Webhook

Kind used as Kubernetes cluster

  1. 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 
  1. Create image
docker build . -t mutate
  1. Push image
kind load docker-image mutate
  1. Create mutating webhook
kubectl apply -f webhook.yaml
  1. Create Mutating Webhook Configuration
kubectl apply -f mutate_admission_ca.yaml
  1. Mutate busbox
kubectl apply -f box.yaml