kubernetes: v1.10 AlwaysPullImages admission control order breaks MutatingAdmissionWebhook functionality like Istio
Is this a BUG REPORT or FEATURE REQUEST?:
Uncomment only one, leave it on its own line:
/kind bug
/kind feature
What happened:
In v1.10, 7c5f9e0bbaff15570f1709e70b7fa6952395d7cd introduced the ability to not worry about admission control order because it’s handled here
AlwaysPullImages is before MutatingAdmissionWebhook. When trying to use Istio sidecar injection, the pod fails to initialize stating
Error creating: pods "sleep-86f6b99f94-qxvq6" is forbidden: spec.initContainers[0].imagePullPolicy: Unsupported value: "IfNotPresent": supported values: "Always"
In v1.9, everything works as expected when placing AlwaysPullImages after MutatingAdmissionWebhook. If you put AlwaysPullImages before MutatingAdmissionWebhook, the same error above occurs.
What you expected to happen:
In v1.10, when AlwaysPullImages and MutatingAdmissionWebhook are turned on, sidecar injection like Istio should work.
How to reproduce it (as minimally and precisely as possible):
- In v1.10, enable
AlwaysPullImagesandMutatingAdmissionWebhookadmission controllers. - Install latest Istio
- Enable sidecar injection
- Enabled istio injection on a namespace ie
kubectl label namespace default istio-injection=enabled - Deploy anything in that namespace
- Run
kubectl describe rs [REPLICA_SET_NAME]. You should see error events similar toError creating: pods "sleep-86f6b99f94-qxvq6" is forbidden: spec.initContainers[0].imagePullPolicy: Unsupported value: "IfNotPresent": supported values: "Always" - Turning off
AlwaysPullImagesseems to fix Istio
Anything else we need to know?:
Environment:
- Kubernetes version (use
kubectl version): v1.10.3 - Cloud provider or hardware configuration: acs-engine
- OS (e.g. from /etc/os-release):
- Kernel (e.g.
uname -a): - Install tools:
- Others:
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 31 (25 by maintainers)
I have a doubt: why enable
AlwaysPullImageswhile inject Istio sidecar with ‘IfNotPresent’ image pull policy?@mbohlool @liggitt @kubernetes/sig-api-machinery-misc I see this as an area that needs to be resolved before admission webhooks can move to GA.
to address #67050 i would support this. as a webhook dev, i want to do the minimum possible and inherit the controls the system puts in place. In my own request I don’t want to have to re-implement the logic from previous admission plugins in my webhook. To this end, I want my mutating webhook to run first so as to be as close to the user’s initial request as possible. This way I can inject my changes (update securityContext, add containers, volumes, etc) without having to know what the name of a service account’s token is. This strategy leads to:
As an example, in order to inject the kerberos sidecar in our webhook we had to generate the following patches in OPA:
where as if the webhook could be run at the beginning of the chain my code would be:
The second block of code eliminates updates to individual container’s service accounts and is portable between k8s distros (since its no longer coded to openshift’s annotations). It also eliminates the need for me to lookup secret names for specific service accounts leading to fewer possible chances to leak information.