Managing Nodes in OpenShift Using oc adm

Managing Nodes in OpenShift Using oc adm

OpenShift, the container management platform created by Red Hat, offers powerful tools for managing nodes in your cluster. Today, we’re going to focus on a few key commands that will assist us in optimizing and maintaining our clusters.

Managing Node Schedulability

First off, sometimes we want to prevent new Pods from being placed on a particular node. This might be necessary, for instance, when we’re planning maintenance or an upgrade. In this case, we can use the command:

oc adm manage-node node-1 --schedulable=false

This command marks the node-1 as unschedulable for new Pods. OpenShift’s scheduler system will not place new Pods on this node.

Evacuating Pods

Sometimes, especially during maintenance, we want to safely evacuate all Pods from a given node. We can do this with the command:

oc adm manage-node node-1 --evacuate --pod-selector=deployment=app-xx

This command evacuates all Pods matching the selector criterion deployment=app-xx from the node node-1. During evacuation, Pods are safely shut down and restarted on another node in the cluster.

Restoring Node Schedulability

After we’re done with maintenance or an upgrade, we want to restore our node to full functionality. We can do this with the command:

oc adm manage-node node-1 --schedulable=true

This command sets the node-1 back to a state where it is schedulable for new Pods. This means the scheduler system can again place new Pods on this node.

Draining a Node

Sometimes, instead of performing these operations separately, we may want to do them all at once. OpenShift offers the drain command, which combines these operations together:

oc adm drain node-1

This command cordons the node-1 for new Pods and evacuates all existing Pods to other nodes. This is a perfect solution for performing maintenance or upgrades on a given node.

Conclusion

The key to effectively managing OpenShift clusters is understanding and utilizing the available tools. These oc adm commands will help you keep your clusters in top shape, no matter what the future brings. However, keep in mind that these operations can temporarily increase the load on other nodes in the cluster as they have to take over additional Pods. Plan accordingly and keep your clusters in excellent condition!

More useful commands: https://github.com/PBujakiewicz/kubectl-oc-cheat-sheet

Dodaj komentarz

Twój adres e-mail nie zostanie opublikowany. Wymagane pola są oznaczone *

Witryna wykorzystuje Akismet, aby ograniczyć spam. Dowiedz się więcej jak przetwarzane są dane komentarzy.