<p>When deleting Openshift apps, I have noticed that deleting its resources (e.g. deploymentConfig) before scaling the app's replicas can cause some odd behavior.  Is it advisable to always scale down first (and why)?  </p>

<p>Yes. I'd say that it is advisable, especially if you're having odd behavior occur because of it. However, it isn't necessary. </p>

<p>Openshift does a great job of managing an application and all of its resources. Unfortunately, it doesn't do a great 'clean up' job. For instance, deleting the deployment config before deleting all relative deployed PODs may lead to orphaned deployments.</p>

<p>To avoid this, first scale down your app (like you suggested in your question):</p>

<pre><code>oc scale dc &lt;app-name&gt; --replicas=0
</code></pre>

<p>Then you can delete all resources in one fell swoop with:</p>

<pre><code>oc delete all --selector app=appname
</code></pre>

<p>This should do the trick. Personally, creating a script to do this helps save time. Here's a simple sample one:</p>

<pre><code>#!/bin/bash

# scale down app to 0
oc scale dc $1 --replicas=0

# delete all resources
oc delete all --selector app=$1
</code></pre>

<p>This would allow you to pass in an actual variable. Let's say you named this script 'oc-delete-app' and your the app you wanted to delete was named 'hello-world'. You'd run:</p>

<pre><code>./oc-delete-app hello-world
</code></pre>
