OpenShift MachineSets and availability zones
Objective
On an OpenShift cluster installed with IPI (installer-provisioned infrastructure), the Machine API manages the nodes like pods: a MachineSet keeps a number of Machines, and each Machine is a cloud VM which becomes a Node. In this lab you will:
- Find the MachineSets created by the installer, one per availability zone
- Create your own MachineSet in a given zone, and scale it up
- Follow a Machine from the VM creation to the Node, and schedule a pod on it
- Understand how a MachineSet selects its Machines, with a classic mistake
Complete this lab in 60 minutes: creating an Azure VM takes 5 to 10 minutes.
Prerequisites
- The shared OpenShift IPI cluster on Azure, logged in with
ocas cluster-admin - The slides
OPENSHIFT.pdf, section Machine API - The lab Pod placement
Warning
Every Machine is a VM billed by Azure. The cluster is shared: only create your MachineSet, never scale it above 1 replica, never modify the MachineSets of the installer, and scale your MachineSet to 0 at the end of the lab.
Setup
Several steps need a second terminal: keep the lab variables in a file, and load it in every new terminal with . $HOME/machineset.env.
INFRA_ID is the cluster name plus a random suffix: the installer prefixes all the cloud resources with it (VMs, disks, network, resource group).
Exercise 1: explore the Machine API
- List the MachineSets, the Machines and the Nodes. How are they linked?
- In which zone is each MachineSet? Which fields of the MachineSet are specific to Azure?
- Which operators and controllers run the Machine API? Which component initializes the Nodes and talks to Azure for them? Look at the namespaces
openshift-machine-apiandopenshift-cloud-controller-manager.
Exercise 2: create your MachineSet
Create a MachineSet $INFRA_ID-worker-$ID-$ZONE, copied from a worker MachineSet of the installer, with:
0replicas- the zone
$ZONE - the label
training/trainee=$IDon the MachineSet and on its nodes
Exercise 3: scale up and follow the Machine
Scale your MachineSet to 1, and follow the Machine until its Node is Ready. Which phases does the Machine go through?
Exercise 4: run a pod on your node
Deploy nginxinc/nginx-unprivileged:1.27-alpine with 2 replicas in the namespace $NS, only on your node. Then check the zone of the pods.
Exercise 5: a Machine without its MachineSet
A colleague wants one more node quickly. They copy your Machine to a new one with a different name, and apply it. What happens? Explain.
Clean up
Scaling down drains the node first: its pods are evicted, then the VM is deleted.
Going further
- Autoscaling: a
ClusterAutoscaler(one per cluster) and aMachineAutoscalerper MachineSet scale the MachineSets when pods arePendingfor lack of resources (trainer demo) - The OpenShift documentation: Machine management, Creating a compute machine set on Azure