K8s Mutating Admission Controller Webhook that will copy labels from a namespace into pods
967
Documentation copied from- https://github.com/devonwarren/pod-labeler-webhook
A Kubernetes Mutating Admission Controller Webhook that will copy labels from a namespace into pods automatically
A MutatingAdmissionWebhook will inject itself in the admission process to intercept changes in objects. In this case this will look at changes to Pod objects specifically. The webhook will take the pod info in, take the pod's namespace, and call the kubernetes api with a service account to gather the labels defined inside that namespace, and then re-apply (based on the LABELS variable) those labels to the pods.
Apply customizations to the yaml files inside the deploy folder as needed
kube-system with something else if you want to install in a different namespacecertificate.yaml file as needed
selfsigned.yaml (if selfsigned-issuer doesn't exist)certificate.yaml with customizationskube-system with alternative namespace if installing elsewheredeployment.yaml file as needed with the following options
mutatingwebhook.yaml as needed
namespaceSelector lines if you want all pods targeted (careful as this will include itself/kube-system)namespaceSelector to select the namespaces you want to target (see namespaceSelector docs)Apply in the following order after making any needed modifications
kubectl apply -f certificate.yaml
kubectl apply -f service-account.yaml
kubectl apply -f deployment.yaml
kubectl apply -f mutatingwebhook.yaml
These variables can be set when running the docker image to customize the functionality
| Variable | Default | Description |
|---|---|---|
| DEBUG | False | If set to True will enable additional output including a dump of input and output objects for debugging purposes |
| LABELS | * | The labels to be copied into pods from their namespaces, if set to '*' will copy all, else can put in multiple values separated by commas |
namespaceSelector (if applicable)DEBUG and check the logskubectl get po -l app=pod-labeler-webhook
Enable the DEBUG variable if needed for additional output
kubectl logs -l app=pod-labeler-webhook
Content type
Image
Digest
Size
77.3 MB
Last updated
about 5 years ago
docker pull devonwarren/pod-labeler-webhook