容器环境变量更改时如何强制重新启动Pod

pap*_*tty 0 pod azure kubernetes azure-kubernetes azure-aks

我正在尝试部署对环境变量有一些更改的映像,但是当我这样做时,我遇到了错误

该吊舱“ENVAR-演示”是无效的:规范:禁止:荚更新可能不会改变比其他领域spec.containers[*].imagespec.initContainers[*].imagespec.activeDeadlineSeconds或者 spec.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”:“来自环境的问候0“,” Command“:null,” Args“:null,” WorkingDir“:”“,” Ports“:null,” EnvFrom“:null,” Env“:[{” Name“:” DEMO_GREETING“,” Value “:”您好,来自环境0“,” Command“:null,” Args“:null,” WorkingDir“:”“,” Ports“:null,” EnvFrom“:null,” Env“:[{” Name“:” DEMO_GREETING“,” Value “:”您好,来自环境

我的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"
Run Code Online (Sandbox Code Playgroud)

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

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

4c7*_*b41 5

实际上,您最好在此用例中使用部署。

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"
Run Code Online (Sandbox Code Playgroud)

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