OpenShift oc create fails with "already exists"
How about using oc replace
:
oc replace --filename file.yml --force
The documentation is perhaps a bit badly worded. What it is saying is that if you try and create an object of a specific type where an object of that type with that name already exists, your attempt to create the new one will be ignored.
The situation you have will occur if you tried to create multiple instances of an application from the same raw resource definitions. There is no way using oc create -f
from a set of raw resource definitions to override names from the command line so a second deployment is distinct.
What you would need to do if you want to create multiple instances from the same resource definitions, is to convert the definitions into a template and parameterise on the name so that you can pass in a different name for different instances. That way there will not be a clash.
Also, when you do create a set of resources, it is usually better to use the one name across all the resource types and not use a different name for each, eg., use just 'my-app-name' for all of them, and not separately, 'my-buildconfig', 'my-imagestream'.
More importantly, you need to ensure you add a label with same key/value on them all so it is easy then to work with them together, including deleting them all in one go.
What is the type of application you are trying to deploy? I can possibly point you at example templates you can use as a guide.
UPDATE 1
If you want to be able run oc create -f
and have it not complain if the resources already exist, but create them if they don't, use oc apply -f
instead.