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 !!
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.
All Kubernetes resources store labels as part of their metadata. You can use "oc get kind name -o yaml" to see a complete, raw resource definition and "oc get kind name --show-labels" to see just labels
The app label used to be standard in apps created by oc new-app but with recent releases of OpenShift it might not be created for all scenarios. Developers are free to add as many labels they wish for their resources and it is common practice to add a common label to all resources related to an application or service to make it easier to track them.