gpt4 book ai didi

azure - 容器环境变量发生变化时如何强制重启pod

转载 作者:行者123 更新时间:2023-12-02 06:16:07 25 4
gpt4 key购买 nike

我正在尝试部署对其环境变量进行了一些更改的图像,但是当我这样做时,我遇到了以下错误

The Pod "envar-demo" is invalid: spec: Forbidden: pod updates may not change fields other than spec.containers[*].image, spec.initContainers[*].image, spec.activeDeadlineSeconds or spec.tolerations (only additions to existing tolerations) {"Volumes":[{"Name":"default-token-9dgzr","HostPath":null,"EmptyDir":null,"GCEPersistentDisk":null,"AWSElasticBlockStore":null,"GitRepo":null,"Secret":{"SecretName":"default-token-9dgzr","Items":null,"DefaultMode":420,"Optional":null},"NFS":null,"ISCSI":null,"Glusterfs":null,"PersistentVolumeClaim":null,"RBD":null,"Quobyte":null,"FlexVolume":null,"Cinder":null,"CephFS":null,"Flocker":null,"DownwardAPI":null,"FC":null,"AzureFile":null,"ConfigMap":null,"VsphereVolume":null,"AzureDisk":null,"PhotonPersistentDisk":null,"Projected":null,"PortworxVolume":null,"ScaleIO":null,"StorageOS":null}],"InitContainers":null,"Containers":[{"Name":"envar-demo-container","Image":"gcr.io/google-samples/node-hello:1.0","Command":null,"Args":null,"WorkingDir":"","Ports":null,"EnvFrom":null,"Env":[{"Name":"DEMO_GREETING","Value":"Hello from the environment

我的yaml。

apiVersion: v1
kind: Pod
metadata:
name: envar-demo
labels:
purpose: demonstrate-envars-new
spec:
containers:
- name: envar-demo-container
image: gcr.io/google-samples/node-hello:1.0
env:
- name: DEMO_GREETING
value: "Hello from the environment-change value"
- name: DEMO_FAREWELL
value: "Such a sweet sorrow"

当我的容器环境变量发生更改时,为什么我无法部署。

我的 pod 处于运行状态,但我仍然需要更改环境变量,然后重新启动我的 pod。

最佳答案

实际上,对于此用例,您最好使用部署。

apiVersion: apps/v1
kind: Deployment
metadata:
name: node-hello
labels:
app: node-hello
spec:
replicas: 3
selector:
matchLabels:
app: node-hello
template:
metadata:
labels:
app: node-hello
spec:
containers:
- name: node-hello
image: gcr.io/google-samples/node-hello:1.0
ports:
- containerPort: 80
env:
- name: DEMO_GREETING
value: "Hello from the environment-change value"
- name: DEMO_FAREWELL
value: "Such a sweet sorrow"

这样您就可以更改环境变量,并且 pod 将使用新的环境变量重新启动

关于azure - 容器环境变量发生变化时如何强制重启pod,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56597244/

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