<p>I wish to use a Mutating WebHook or Istio to automatically inject a Sidecar container and a shared volume between the existing container and sidecar to a k8s deployment in a remote cluster for log archiving. The issue is that the mount path required for each pod differs and is provided as a user-provided input.</p>

<p>What would be the best way to pass this user-defined information to the webhook?</p>

Ranika Nisal
<p>The best place to store that kind of data for the mutating webhook to read from are <a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/" rel="nofollow noreferrer">annotations</a>.</p>

<p>More useful <a href="https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#extending-with-annotations" rel="nofollow noreferrer">information</a> about annotations and webhooks with examples. <a href="https://kubernetes.io/docs/tasks/inject-data-application/downward-api-volume-expose-pod-information/#capabilities-of-the-downward-api" rel="nofollow noreferrer">Annotations</a> can also be accessed from containers inside a pod.</p>

<p>Note that if the mount path is different for different pods, then we need to get those paths from somewhere.</p>
