FreeKB - OpenShift Restart deployment using the oc scale command (replicas)
OpenShift - Restart deployment using the oc scale command (replicas)

If you are not familiar with the oc command, refer to OpenShift - Getting Started with the oc command.

Before scaling a deployment, you will need to issue the oc login command to sign into OpenShift, and then the oc get deployments command to return the deployments in the project.

oc get deployments -n <your project>

 

Something like this should be returned.

NAME            DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
app001          1         1         1            1           205d

 

The -o yaml or -o json options can be used to view the current number of replicas being used by the deployment.

oc get deployments -n <your project> -o yaml | grep -i replicas

 

Something like this should be returned.

replicas: 1

 

The oc scale command can be used to scale the deployment down.

oc scale deployment/<your deployment> -n <your project> --replicas=0

 

Something like this should be returned.

deployment.apps/app001 scaled

 

Once scaled to 0, the oc get deployments command should return something like this.

NAME            DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
app001          0         0         0            0           205d

 

And the oc get pods command should return something like this.

No resources found in <your project> namespace.

 

You can then scale the deployments back up.

oc scale deployment/<your deployment> -n <your project> --replicas=1

 

Then you can watch for the pod to restart.

watch oc get pods -n <your project>

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter c7d2f in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |