<p>I need to add an sidecar to run alongside my main container in K8S during runtime. I have currently done this using a script which edits the deployment.yaml to add all necessary parts including the container and any shared volume mounts etc. This currently works but is a bit ugly. I started looking at Istio for automatic sidecar injection but the documentation is a bit unclear to me. <br></p>

<ol>
<li>Can I provide user defined values for the sidecar when injecting the sidecar ( such as image for the container and paths for shared volume mounts</li>
<li>Does it support injection for specific types are will it only inject sidecars for pod types ?</li>
</ol>

JAbeywrdana
<p>istio, as many other kube-native apps, uses k8s <a href="https://kubernetes.io/blog/2019/03/21/a-guide-to-kubernetes-admission-controllers/" rel="nofollow noreferrer">admission-controller</a> and the <a href="https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/" rel="nofollow noreferrer">admission-webhooks</a> api to <a href="https://kubernetes.io/docs/tasks/run-application/update-api-object-kubectl-patch/" rel="nofollow noreferrer">patch</a> the deployment and inject the sidecar, take a look at <a href="https://github.com/istio/istio/blob/master/pkg/kube/inject/inject.go" rel="nofollow noreferrer">https://github.com/istio/istio/blob/master/pkg/kube/inject/inject.go</a></p>
