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

时间:2019-06-14 11:27:11

标签: docker kubernetes pod azure-kubernetes

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

  

广告连播“ envar-demo”无效:规范:禁止:广告连播更新可能不会   更改spec.containers[*].image以外的其他字段,   spec.initContainers[*].imagespec.activeDeadlineSeconds或   spec.tolerations(仅对现有公差的补充)   {“ Volumes”:[{“ Name”:“ default-token-9dgzr”,“ HostPath”:null,“ EmptyDir”:null,“ GCEPersistentDisk”:null,“ AWSElasticBlockStore”:null,“ GitRepo”:null,“机密”:{“ 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“:”您好   来自环境

我的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。

1 个答案:

答案 0 :(得分:4)

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

TypeError: s() missing 1 required positional argument: 'self'

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

相关问题