Should I scale down Openshift app's replicas before deleting its resources? Should I scale down Openshift app's replicas before deleting its resources? kubernetes kubernetes

Should I scale down Openshift app's replicas before deleting its resources?


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

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.

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

oc scale dc <app-name> --replicas=0

Then you can delete all resources in one fell swoop with:

oc delete all --selector app=appname

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

#!/bin/bash# scale down app to 0oc scale dc $1 --replicas=0# delete all resourcesoc delete all --selector app=$1

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:

./oc-delete-app hello-world


It doesn't really matter. I don't know what version you're on, but Openshift should take care of it for you. Yes, there will be some things left over, but for the most part, it won't affect anything else.