Overview of the Machine API and resources provided by the Machine API Operator
This blog post demonstrates the Overview of the Machine API and resources provided by the Machine API Operator, how to scale an OpenShift cluster up or down automatically based on traffic load using the Cluster Autoscaler and Machine API MachineAutoscaler. Ensuring that the cluster only employs the number of nodes necessary to manage the current load, can help to conserve resources and reduce energy expenses.
To raise or reduce the worker nodes of an OpenShift cluster, we used the terms “scale up” or “scale down” throughout this blog instead of “scale out” or “scale in.”
Overview of machine API
The Machine API comprises both unique OpenShift Container Platform resources and primary resources based on the Cluster API(CAPI) project upstream.
After the cluster installation is complete for OpenShift Container Platform 4.12 clusters, the Machine API handles all node host provisioning management tasks. This solution enables an elastic, dynamic provisioning technique on top of public or private cloud infrastructure, including Baremetal, with OpenShift Container Platform 4.12.
The following resources are made available by the Machine API Operator:
- MachineSet
- Machine
- ClusterAutoscaler
- MachineAutoscaler
The following unique resources provide your cluster with additional capabilities:
Computer autoscaler
In a cloud, computing machines are automatically scaled via the MachineAutoscaler resource. The machine autoscaler maintains the range of nodes you specify for the lowest and maximum scaling bounds for nodes in a given compute machine set.
After a ClusterAutoscaler object is present, the MachineAutoscaler object becomes active. The ClusterAutoscalerOperator object makes resources for MachineAutoscaler and ClusterAutoscaler available. A Kubernetes controller that keeps track of changes to MachineSet objects is called the MachineAutoscaler. When the MachineAutoscaler notices that the cluster has fewer machines than needed, it will add new devices of the designated type.
Autoscaler for clusters
The upstream cluster autoscaler project is the foundation of this resource. By expanding the compute machine set API, it is integrated with the Machine API in the OpenShift Container Platform implementation. A Kubernetes controller called the Cluster Autoscaler keeps an eye out for pods that can’t be scheduled on any of the cluster’s active nodes. New nodes will be added to the cluster when the Cluster Autoscaler discovers pods that cannot schedule themselves.
The following methods for cluster management are possible when using the cluster autoscaler:
- Set scaling constraints for resources like cores, nodes, RAM, and GPU across the entire cluster.
- Set the priority so that the cluster will prioritize pods and prevent the addition of new nodes for less crucial pods.
- Configure the scaling policy such that nodes can only be scaled up.