I am doing Lab, there i am trying to save file through OC edit command, but it is showing error.
student@workstation ~]$ oc edit deployment/hello
A copy of your changes has been stored to "/tmp/oc-edit-1fi7k.yaml"
error: Edit cancelled, no valid changes were saved.
Let us know , how to save file through oc edit command?
issue get resolved now !! i should have checked the error reported while it not saving and storing the file to /tmp/oc-edit-XXX ( screenshots attached )
YAML error: found character that cannot start any token
used tab instead of Space - as Yaml dont accept tabs and expecting spaces
Thanks for your support !!
I had the same issue at the same lab! I would go crazy since everything seemed normal except using tab instead of space! This also resolved my issue. Thanks a lot!
Clarification comment: oc edit does not save anything anywhere. You will not find a file with the oc edit contents of you last session. It reads from OpenShift and sends back to OpenShift, if OpenShift doesn't likes what it got and rejects it, you are left with no "file" to look at and make fixes.
An alternative is to export the resource to a file, edit the file, and them send it back to OpenShift:
$ oc get kind/name > resource.yaml
$ vi resource.yaml
$ oc apply resource.yaml
You are correct that the file is saved on tmp (so it can be fed to vi or another editor) but oc edit will not pick that file for you and reuse it. So "conceptually" it is not saved... not to mention that any content in tmp could disappear without notice.
But you could fech the file from tmp, edit it, and feed it into oc apply.
Yes , ofcourse oc edit wont pick . But i mentioned the output is save to /tmp/ by oc edit when it rejects the changes .So conceptually its save :-) anyway .. thanks for your sharing !! cheers
a bit late to the patry but i hit the same issue,
the problem is with the indentation if you dont indent properly (mashing space)
it wont save so it doesnt matter if you export it as yaml or not if you dont have proper indentation openshift will not accept it .
since the topic is already bumped i have another question for the particular exercise
oc delete all -l app=hello-limit
where is that label app stored ? and how can i view other labels ? I checked if it was on the node but that was not the case.