kubernetes: initContainers does not accept imagePullSecrets
What happened: initContainers does not accept imagePullSecrets. No way to configure a secret so initContainers can connect to a private repository.
What you expected to happen: Adding an imagePullSecrets under spec should work for both container and initContainers
How to reproduce it (as minimally and precisely as possible): Have a template with both container and initContainer. Define a imagePullSecret under spec. Use a private repository where you authenticate with secret.
You will get imagePullBackoff and cannot connect to repository for your images that need to be pulled from your init containers.
Anything else we need to know?:
Environment:
- Kubernetes version (use
kubectl version): 1.8.11 - Cloud provider or hardware configuration: Docker EE with Kubernetes, DTR (Docker Trusted Registry)
- OS (e.g. from /etc/os-release): alpine
- Kernel (e.g.
uname -a): - Install tools:
- Others:
/kind bug
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 4
- Comments: 55 (21 by maintainers)
ends with
Just encountered this issue. Setting
imagePullSecretsat the top level which should apply tocontainersandinitContainersbut not seeing that working. Init containers are failing to pull down the Docker image.I think the reason why this issue breaks and then seems to magically work is if the Kubernetes worker nodes download the Docker image from the root
containersthen the next timeinitContainersruns it has the Docker image cached (no auth needed). I was able to replicate this error if the Docker image is brand new (not on any workers) and failing to auth usingimagePullSecrets.Running:
It still does not work. :< initContainers can’t pull images from private repo.
unauthorized: authentication required/reopenI’m on v1.12.6-3+602d21b1679fa5. init containers still don’t seem to use imagePullSecrets from the spec.
seems like it is working now - I’ve got all private repos for both containers and initContainers and it works with imagePullSecrets defined in the spec block.
@Jyny: You can’t reopen an issue/PR unless you authored it or you are a collaborator.
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
The fix is:
imagePullSecretsmust be specified on top level underspec.template.spec. It then is used for both the initContainers and normal containers.