Sidecar injection with CNI enabled on AKS - failed to setup network for sandbox plugin type="consul-cni" name="consul-cni" failed (add): error retrieving pod: Unauthorized #4442
Labels
type/bug
Something isn't working
Community Note
Overview of the Issue
Consul 1.3.1 with CNI and Connect Injector installed; AKS Kubernetes 1.30.6; the CNI is unable to pull images from our private registry. Switching the CNI off, things work fine. Switching it on results in the below error for our application pods which get the sidecar injected:
The same error can be seen whether we have our application deployment configured for sidecar injection or not. If I simply switch off the injection annotation, I still see the same error above even after redeploying with the change and new pods coming up (and just to confirm - no, the initContainer and container are not there when the injection annotation is turned off; that part is working properly, however the error remains the same). Only when I switch off the CNI altogether and run helm upgrade, then my application workload pods can start up (and if the deployment annotation is turned on, then injection is working properly). I want to use the CNI so that I can lower the privilege level of my application workload pods.
values.yaml
Reproduction Steps
We see this when we deploy our app. I can't share the app images or manifests in full but can answer questions. The application and sidecar images both come from our private registry, however they are stored in separate repos with different credentials.
Therefore, our application pods are defined with 2 secret names listed in imagePullSecrets, in order for the pod to try to pull using both
kind: Secret
type: kubernetes.io/dockerconfigjson
resources and successfully pull the images. This works fine when CNI is disabled. Based on the errors coming when CNI is enabled but injection being disabled, and the fact that our application pods work properly with 2 image pull secrets when we have the CNI disabled, this seems to indicate that the consul-cni service account is missing something related to accessing the image pull secret.Logs
Because this happens during pod sandbox creation by the kubelet, there are no container logs in our app pod which I can share; only the event output I provided above. The consul-cni pod logs on the same node where a failing pod is located have no output related to this failure nor any output at all during the timestamps when the image pull fails are happening, so there is nothing to indicate what is happening there either.
Expected behavior
I expected our app pods to come up properly with the sidecar having reduced privileges and no initContainer being present.
Environment details
We use Azure CNI plugin, the rest of the requested details are seen above.
Additional Context
The text was updated successfully, but these errors were encountered: