Install Assisted Labs App and get OpenShift Hands-on Labs and Order OpenShift Cluster for your learning.

Overview of OpenShift Machine Config and Machine Config Pools
Note: Join our Openshift Tips and Tricks WhatsApp Channel and get regular Updates.
OpenShift utilizes Machine Config and Machine Config Pools as essential components for managing the configuration of nodes within a cluster, specifically leveraging Red Hat CoreOS (RHCOS). These constructs allow administrators to define and apply system-level configurations across different types of nodes, ensuring consistency and enabling automated management.
Machine Config
A Machine Config is an object that specifies the configuration settings for a node. These settings can include:
- User management: Creation and deletion of users.
- Kernel parameters: Modifications to kernel settings.
- File system configurations: Management of directories, permissions, and files.
- Systemd units: Configuration of system services.
Machine Configs are crucial for maintaining the desired state of nodes by applying necessary changes and detecting configuration drift. Each Machine Config is associated with a specific role (e.g., worker, master) and is applied to nodes based on these roles.
Example of a Machine Config
Here’s a simplified example of a Machine Config that sets a specific file configuration:
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
labels:
machineconfiguration.openshift.io/role: worker
name: 100-critical-config
spec:
config:
ignition:
version: 3.2.0
storage:
files:
- contents:
source: data:,critical_config_data%0A
mode: 420
overwrite: true
path: /etc/sensitive.conf
This config applies to worker nodes, creating or modifying the file /etc/sensitive.conf
Machine Config Pool
A Machine Config Pool (MCP) is a collection of nodes that share the same configuration settings defined by one or more Machine Configs. MCPs allow for organized management of configurations across similar node types. OpenShift typically includes default pools like:
- Master Pool: Contains all master nodes.
- Worker Pool: Includes all worker nodes, which can be further divided into sub-pools such as application and infrastructure pools.
Custom MCPs can also be created to apply specific configurations to subsets of nodes based on their roles or other criteria.
Creating a Machine Config Pool
To create a new MCP, you define it in YAML format, specifying which nodes it should manage. For instance:
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfigPool
metadata:
name: gpu
spec:
machineConfigSelector:
matchExpressions:
- {key: machineconfiguration.openshift.io/role, operator: In, values: [worker,gpu]}
nodeSelector:
matchLabels:
node-role.kubernetes.io/gpu: ""
Refer the Official Operator page: Git Hub Machine Config Operator URL
How do you create a new MachineConfigPool
oc create a new MachineConfigPool in OpenShift, follow these steps:
- Label the Nodes: First, ensure that the nodes you want to include in the new pool are labeled appropriately. For example, if you want to create a pool for GPU nodes, you would label them as follows:
kubectl label node node-role.kubernetes.io/gpu=””
Define the MachineConfigPool: Create a YAML file for your new MachineConfigPool. Here’s an example configuration for a GPU node pool:
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfigPool
metadata:
name: gpu
spec:
machineConfigSelector:
matchExpressions:
- key: node-role.kubernetes.io/gpu
operator: Exists
nodeSelector:
matchLabels:
node-role.kubernetes.io/gpu: ""
Apply the Configuration: Use kubectl
to apply the configuration file you just created:
oc apply -f yourfilename.yaml
Verify the Creation: After applying the configuration, check the status of your MachineConfigPool to ensure it was created successfully:
oc get mcp
Monitor Updates: If you add any MachineConfigs associated with this new pool, the MachineConfig Operator will automatically apply those configurations and initiate a rolling update of the nodes in the pool.
Troubleshooting:
- oc get mc
- oc get mcp
- oc get mcp worker -oyaml – identify the status of degraded node
- oc get machineconfigpool -o wide – This command provides an overview of all MachineConfigPools, showing their status and the number of nodes in each pool.
- oc logs -f daemonset/machine-config-daemon -n openshift-machine-config-operator – View Logs of Machine Config Daemon:
You have reached at the end of the article. Please note, these commands may vary based on the environment and problem scenarios.
YouTube reference by MKDEV channel – very useful one.
Yay! 🎉 You made it to the end of the article!