I run
kubectl edit deployment to change the version of one of my pods (this commands opens a temp file in my text editor and then I usually edit and close this temp file) and even before I close this temp file in my text editor I can see the following note in my bash.
Edit cancelled, no changes made. It was OK before I installed fish and I tried to switch to bash but it doesn't help either.
How can I fix it?
24 Answers
Things like this are most likely caused by it opening an editor that forks off instead of staying.
That means you'll want to set $EDITOR to an editor that does wait. E.g. nano, vim or emacs should work, and e.g. if you use sublime text you'll have to use subl -w to explicitly tell it to wait.
It's not quite clear which shell you're running at the moment. If it's bash, run export EDITOR="subl -w", in fish run set -gx EDITOR subl -w (or "subl -w" if you use fish < 3.0).
A refinement to the ample answer provided by @faho.
An approach with the $EDITOR variable achieves the goal but changes the default command-line editor. This might affect other programs dependent on this setting (e.g. crontab, edquota).
It'd be better to rely on the $KUBE_EDITOR variable. For example for the one-time use you might try:
KUBE_EDITOR="nano" kubectl edit deploy/hello-world (Please see Editing Resources)
3With vim, when you try to save it saves an edited copy which is specified in /tmp/ path, along with the error message, when you quit the editor.
This is equivalent to using get the resource, edit it in text editor, and then apply the resource with the updated version:
kubectl get deployment my-nginx -o yaml > /tmp/nginx.yaml vim /tmp/nginx.yaml kubectl apply -f /tmp/nginx.yaml configured then remove the file
rm /tmp/nginx.yaml So basically use apply on the file saved in the /tmp/<file.yaml>
This issue may also happen when changes made by you are not picked by an kubectl eg. because of incorrect YAML.
- Please make other change that you are sure of.
- After saving check if still getting the same problem
Example issue replication:
- the spec.selector.app: xxx" is invalid as it is duplicated;
- the last one will remain; the first will be ignored.
- so if you just added the first one - it no changes will be made.
spec: clusterIP: 10.152.183.151 clusterIPs: - 10.152.183.151 ports: - port: 80 protocol: TCP targetPort: 80 selector: app: xxx app: rng