如何在使用“kubectl run"命令时传递图像拉取密码? [英] How to pass image pull secret while using 'kubectl run' command?

查看:16
本文介绍了如何在使用“kubectl run"命令时传递图像拉取密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 kubectl run 命令从私有注册表中提取映像并从中运行命令.但我没有看到指定图像拉取密码的选项.看起来不可能将图像机密作为运行命令的一部分传递.

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.

是否有其他选项可以使用 kubectl 拉取容器并运行命令?命令输出应该可以在控制台上看到.同样,一旦命令完成,pod 就会死亡.

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.

推荐答案

如果指定正确,您可以使用覆盖,它最终是一个数组,我花了一些时间才弄清楚,以下适用于 Kubernetes至少 1.6:

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='{ "spec": { "template": { "spec": { "imagePullSecrets": [{"name": "your-registry-secret";}] } } } }'

例如

kubectl run -i -t hello-world --rm --generator=run-pod/v1 
--image=eu.gcr.io/your-registry/hello-world 
--image-pull-policy="IfNotPresent" 
--overrides='{ "spec": { "template": { "spec": { "imagePullSecrets": [{"name": "your-registry-secret"}] } } } }'

这篇关于如何在使用“kubectl run"命令时传递图像拉取密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆