Kubernetes MutatingWebhookConfiguration Create other objects

8/30/2019

I'm using a MutatingWebhookConfiguration in order to inject a sidecar app into my pod. This works fine, but I'd like now to be able to create a new service for this sidecar. Anyway my question is a bit broader: can we from a webhook create other objects or are we limited to mutate only the request object ?

Do you have any solution ?

-- benjamin.d
kubernetes

1 Answer

8/30/2019

Kubernetes doesn't have such a mechanism: Mutating Webhooks for an outside object or manifest.

In essence, you can concatenate as many objects/manifests in a Kubernetes config file. So, you could have a manifest that injects the sidecar component together with the creation of a service. You can separate the manifests using a --- line, which signals the start of a new document in YAML. Then apply the whole configuration files with:

$ kubectl apply -f <config-file>.yaml

More background on this answer.

-- Rico
Source: StackOverflow