创建一个pod脚本
busybox-pod.yaml
```yaml
apiVersion: v1
kind: Pod
metadata:
name: busybox
namespace: dev
spec:
containers:
- name: busybox
image: busybox
command:
- sleep
- "3600"
```
我们来应用这个模板
```shell
# kubectl apply -f busybox-pod.yaml
pod "busybox" configured
```
现在我们来修改这个模板,例如改一下休眠时间
busybox-pod.yaml
```yaml
apiVersion: v1
kind: Pod
metadata:
name: busybox
namespace: dev
spec:
containers:
- name: busybox
image: busybox
command:
- sleep
- "3700"
```
再次应用这个模板
```shell
# kubectl apply -f busybox-pod.yaml
The Pod "busybox" is invalid: spec: Forbidden: pod updates may not change fields other than `containers[*].image` or `spec.activeDeadlineSeconds`
```
如果修改其他配置,可能收到如下报错:
```
The Pod "busybox" is invalid: spec.containers: Forbidden: pod updates may not add or remove containers
```
这时,我们需要先将容器删除再重现创建
```shell
# kubectl delete pod busybox -n dev
pod "busybox" deleted
```
结论:pod无法更新