<p>Attempting to create a set of resources based on a file via <code>oc create</code> fails if they already exist.</p>

<p>According to the <a href="https://docs.openshift.com/enterprise/3.2/cli_reference/basic_cli_operations.html#create" rel="noreferrer">docs here</a> <code>oc create</code> should:</p>

<blockquote>
  <p>Parse a configuration file and create one or more OpenShift Enterprise
  objects ... <strong><em>Any existing resources are ignored.</em></strong></p>
</blockquote>

<p>(emphasis mine).</p>

<p>I can't see any config options for this command or globally that would alter this behaviour and it seems to me to be counter to the docs.</p>

<p>The command I ran is <code>oc create -f some.file</code></p>

<p>The output is:</p>

<pre><code>Error from server: services 'my-app' already exists
Error from server: buildconfigs 'my-app' already exists
Error from server: imagestreams 'my-app' already exists
Error from server: deploymentconfigs 'my-app' already exists
Error from server: routes 'my-app' already exists
Error from server: secrets 'my-app' already exists
</code></pre>

<p>It also exits with a non-zero exit code, so it's not just a warning. Am I missing something obvious here or misunderstanding what the documentation is saying?</p>

<p>I just want to be able to apply this file and ensure the state of the OpenShift project afterwards.</p>

<p>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.</p>

<p>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 <code>oc create -f</code> from a set of raw resource definitions to override names from the command line so a second deployment is distinct.</p>

<p>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.</p>

<p>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'.</p>

<p>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.</p>

<p>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.</p>

<hr>

<p>UPDATE 1</p>

<p>If you want to be able run <code>oc create -f</code> and have it not complain if the resources already exist, but create them if they don't, use <code>oc apply -f</code> instead.</p>
