gpt4 book ai didi

Kubernetes 部署 : Editing the 'spec' of a pod's YAML file fails

转载 作者:行者123 更新时间:2023-12-04 23:40:04 24 4
gpt4 key购买 nike

envspec.containers 中添加的元素使用 K8 仪表板的 Edit 的 pod 不会被保存。有谁知道问题是什么?

有没有其他方法可以将环境变量添加到 pods/容器?

通过使用 nano 编辑文件来执行相同操作时出现此错误:

# pods "EXAMPLE" was not valid:
# * spec: Forbidden: pod updates may not change fields other than `containers[*].image` or `spec.activeDeadlineSeconds`

谢谢。

最佳答案

并非所有字段都可以更新。这个事实有时会在 kubectl explain 中提到。对象的输出(以及您得到的错误列出了可以更改的字段,因此其他字段可能无法更改):

$ kubectl explain pod.spec.containers.env
RESOURCE: env <[]Object>

DESCRIPTION:
List of environment variables to set in the container. Cannot be updated.

EnvVar represents an environment variable present in a Container.

如果您使用 Deployment object 部署 Pod ,然后您可以使用 kubectl edit 更改该对象中的环境变量因为部署将推出具有变量更改的 Pod 的更新版本,并杀死没有变化的旧 Pod。显然,该方法并没有就地更改 Pod,但它是获得所需内容的一种方法。

您的另一个选择可能是使用 ConfigMaps .如果您使用卷插件方法安装 ConfigMap 并且您的应用程序被编写为了解卷的更改并在更改时使用新设置重新加载自身,则它可能是一个选项(或至少为您提供其他可能适用的想法你)。

关于Kubernetes 部署 : Editing the 'spec' of a pod's YAML file fails,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40359602/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com