kubernetes: Validation error on kubectl apply after kubectl edit
What happened:
Attempting to kubectl apply a manifest whose resources have been previously modified using kubectl edit (see steps to reproduce below) raises a validation error.
kubectl apply -f manifest.yml
configmap/example unchanged
The Deployment "example" is invalid: spec.template.spec.containers[0].env[0].valueFrom: Invalid value: "": may not be specified when `value` is not empty
What you expected to happen: Manifest should be successfully applied.
If this flow is not supported, the user should receive a useful error message indicating what the problem is (e.g. “Resource has been modified since last applied configuration, cannot update”).
How to reproduce it (as minimally and precisely as possible):
- Create
manifest.ymlwith the following contents:
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: example
namespace: default
spec:
replicas: 1
selector:
matchLabels:
cluster: example
template:
metadata:
labels:
cluster: example
spec:
containers:
- command: [ sleep, '3600' ]
env:
- name: EXAMPLE
valueFrom:
configMapKeyRef:
name: example
key: example
image: alpine
name: sleep
---
apiVersion: v1
data:
example: value
kind: ConfigMap
metadata:
name: example
namespace: default
-
Apply manifest
kubectl apply -f manifest.yml -
Edit the example deployment to change the environment variable to point to a value instead of a configmap key.
kubectl edit deployment example
- name: EXAMPLE
value: 'example'
- Repeat step 2.
kubectl apply -f manifest.yml
Anything else we need to know?:
Environment:
- Kubernetes version (use
kubectl version):
Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.2", GitCommit:"66049e3b21efe110454d67df4fa62b08ea79a19b", GitTreeState:"clean", BuildDate:"2019-05-16T16:23:09Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.7", GitCommit:"0c38c362511b20a098d7cd855f1314dad92c2780", GitTreeState:"clean", BuildDate:"2018-08-20T09:56:31Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
- Cloud provider or hardware configuration: AWS
- OS (e.g:
cat /etc/os-release): Debian GNU/Linux 9 (stretch) - Kernel (e.g.
uname -a):
Linux ip-10-110-247-162 4.9.0-7-amd64 #1 SMP Debian 4.9.110-3+deb9u2 (2018-08-13) x86_64 GNU/Linux
- Install tools: kops
- Network plugin and version (if this is a network-related bug): N/A
- Others: N/A
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 19 (7 by maintainers)
https://github.com/kubernetes/enhancements/issues/1027 will fix it (and also depends on server-side apply)