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

8/20/2016

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)?

-- JWAL
docker
kubernetes
openshift
redhat

2 Answers

8/20/2016

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 0
oc scale dc $1 --replicas=0

# delete all resources
oc 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
-- wynshaft
Source: StackOverflow

8/21/2016

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.

-- CodingLegend
Source: StackOverflow