tumblr / k8s-sidecar-injector

Kubernetes sidecar injection service
Apache License 2.0
345 stars 75 forks source link

make sure we remove any volumeMounts that were precreated when inject… #40

Closed byxorna closed 4 years ago

byxorna commented 4 years ago

…ing a serviceAccount

What and why?

I missed one edge case in https://github.com/tumblr/k8s-sidecar-injector/pull/39 - any containers that exist in the admission requested pod before we inject a serviceAccount will already have had any VolumeMounts for the serviceaccount's token created, when automountServiceAccountToken:true. This is a bit annoying, and causes users of ServiceAccount injections to have original containers continue to use the default-token-* mount, whereas injected containers use the correct ${serviceAccountName}-token-* mount that is added by the ServiceAccountController after processing the MWAC injection.

Testing Steps

Reviewers

Required reviewers: @byxorna Request reviews from other people you want to review this PR in the "Reviewers" section on the right.

:warning: this PR must have at least 2 thumbs from the MAINTAINERS.md of the project before merging!