The Pod "nginx-pod" 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) core.PodSpec{ Volumes: []core.Volume{ { Name: "nginx-config", VolumeSource: core.VolumeSource{ ... // 17 identical fields FC: nil, AzureFile: nil, ConfigMap: &core.ConfigMapVolumeSource{ - LocalObjectReference: core.LocalObjectReference{Name: "nginx-config"}, + LocalObjectReference: core.LocalObjectReference{Name: "nginx-configmap"}, - Items: nil, + Items: []core.KeyToPath{{Key: "nginx.conf", Path: "nginx.conf"}}, DefaultMode: &420, Optional: nil, }, VsphereVolume: nil, AzureDisk: nil, ... // 7 identical fields }, }, {Name: "default-token-276dd", VolumeSource: core.VolumeSource{Secret: &core.SecretVolumeSource{SecretName: "default-token-276dd", DefaultMode: &420}}}, }, InitContainers: nil, Containers: []core.Container{ { ... // 7 identical fields Env: nil, Resources: core.ResourceRequirements{}, VolumeMounts: []core.VolumeMount{ { Name: "nginx-config", - ReadOnly: false, + ReadOnly: true, MountPath: "/etc/nginx/nginx.conf", SubPath: "nginx.conf", ... // 2 identical fields }, {Name: "default-token-276dd", ReadOnly: true, MountPath: "/var/run/secrets/kubernetes.io/serviceaccount"}, }, VolumeDevices: nil, LivenessProbe: nil, ... // 10 identical fields }, }, EphemeralContainers: nil, RestartPolicy: "Always", ... // 25 identical fields }
时间: 2024-02-01 14:12:51 浏览: 208
nginx-1.18.0-2.el7.ngx.x86-64.rpm安装包(含有部署手册)
这个错误是因为你试图更新一个 Pod 的 spec 字段中不允许被更改的字段。根据错误信息,你只能更改 `spec.containers[*].image`, `spec.initContainers[*].image`, `spec.activeDeadlineSeconds` 或者 `spec.tolerations` 字段,而其他字段都不能更改。
具体来说,你试图更改 `spec.volumes[*].name` 为 `"nginx-configmap"`,但是这个字段并不在允许更改的列表中。你需要将这个字段更改为允许更改的字段之一,比如 `spec.containers[*].image` 或者 `spec.tolerations`。
另外,你还试图将 `spec.volumes[*].configMap.items` 字段更改为 `[]`,这也是不允许的。你可以将这个字段更改为一个非空的数组,比如 `[{key: "nginx.conf", path: "nginx.conf"}]`。
阅读全文