Warm tip: This article is reproduced from stackoverflow.com, please click
kubectl kubernetes

How to pass image pull secret while using 'kubectl run' command?

发布于 2020-04-08 23:39:32

I am trying to use kubectl run command to pull an image from private registry and run a command from that. But I don't see an option to specify image pull secret. It looks like it is not possible to pass image secret as part for run command.

Is there any alternate option to pull a container and run a command using kubectl? The command output should be seen on the console. Also once the command finishes the pod should die.

Questioner
noorul
Viewed
91
Elmar Weber 2017-11-07 19:19

You can use the overrides if you specify it right, it's an array in the end, that took me a bit to figure out, the below works on Kubernetes of at least 1.6:

--overrides='{ "apiVersion": "v1", "spec": { "imagePullSecrets": [{"name": "your-secret"}] } }'

for example

kubectl run -i -t hello-world --restart=Never --rm=true \ --image=eu.gcr.io/your-registry/hello-world \ --overrides='{ "apiVersion": "v1", "spec": { "imagePullSecrets": [{"name": "your-registry-secret"}] } }'