A ValidatingAdmissionWebhook can be used to avoid applying faulty Peer configurations to the cluster.
A ValidatingWebhookConfiguration is a Kubernetes resource that can be used to dynamically specify a service (i.e. the webhook server) that should validate operations (e.g.
CREATE, etc.) on a particular resource (e.g. Kilo Peers).
Once such a configuration is applied, the Kubernetes API server will send an AdmissionReviewRequest to the webhook service every time the specified operations are applied to the resource of the specified type.
With regard to the failure policy, the API server will apply the requested changes to a resource if the request was answered with
"allowed": true, or deny the changes if the answer was
In case of Kilo Peer Validation, the specified operations are
CREATE, the resources are
Peers, and the default
failurePolicy is set to
View the full ValidatingWebhookConfiguration here.
Apply the Service, the Deployment of the actual webserver, and the ValidatingWebhookConfiguration with:
kubectl apply -f https://raw.githubusercontent.com/squat/kilo/blob/main/manifests/peer-validation.yaml
The Kubernetes API server will only talk to webhook servers via TLS so the Kilo-Peer-Validation server must be given a valid TLS certificate and key, and the API server must be told what certificate authority (CA) to trust. The above manifest will use kube-webhook-certgen to generate the requiered certificates and patch the ValidatingWebhookConfiguration.