How to create a MachineSet for VMware in OCP 4 UPI installations

Solution Verified - Updated

Environment

  • Red Hat OpenShift Container Platform (RHOCP)
    • UPI Installation
    • 4.5 and Higher
  • VMware vSphere 6.7+

Issue

  • Are MachineSets supported when using the VMware UPI method in OpenShift Container Platform 4.5?
  • How to create a MachineSet for VMware in OpenShift 4.5?

Resolution

Disclaimer 1: This method is NOT supported if platform in install-config.yaml has been set to "none", as per the documentation

Disclaimer 2: Links contained herein to external website(s) are provided for convenience only. Red Hat has not reviewed the links and is not responsible for the content or its availability. The inclusion of any link to an external website does not imply endorsement by Red Hat of the website or their entities, products or services. You agree that Red Hat is not responsible or liable for any loss or expenses that may result due to your use of (or reliance on) the external site or content.

Starting in OpenShift 4.5, MachineSets are supported for VMware based clusters using the IPI and UPI installation method. For the UPI installation additional tasks are required to utilise MachineSets.

  • A Tag needs to be created inside the vCenter instance based on the Cluster API name. These tags are utilised by the MachineSet to associate the OpenShift Nodes to the provisioned Virtual Machines.
  • To get the Cluster API name, if the Cluster has not been installed, retrieve it from the metadata.json or .openshift_install_state.json files located in the cluster's installation directory by running either of the two following commands:
$ jq -r .infraID metadata.json
ocp45-2tdrm

$ jq -r '."*installconfig.ClusterID".InfraID' .openshift_install_state.json
ocp45-2tdrm
  • If the cluster has already been installed, the Cluster API name can be retrieved by running the following command:
$ oc get infrastructure cluster -o jsonpath='{.status.infrastructureName}{"\n"}'
  • Create the new MachineSet with a definition similar to this and replace the values with those that match the environment:
        apiVersion: machine.openshift.io/v1beta1
        kind: MachineSet
        metadata:
            creationTimestamp: null
            labels:
                machine.openshift.io/cluster-api-cluster: <Cluster API Name>
            name: <MachineSet Name>
            namespace: openshift-machine-api
        spec:
            replicas: <Number of Replicas>
            selector:
                matchLabels:
                    machine.openshift.io/cluster-api-cluster: <Cluster API Name>
                    machine.openshift.io/cluster-api-machineset: <MachineSet Name>
            template:
                metadata:
                    creationTimestamp: null
                    labels:
                        machine.openshift.io/cluster-api-cluster: <Cluster API Name>
                        machine.openshift.io/cluster-api-machine-role: worker # e.g. worker, infra, master
                        machine.openshift.io/cluster-api-machine-type: worker # e.g. worker, infra, master
                        machine.openshift.io/cluster-api-machineset: <MachineSet Name>
                spec:
                    providerSpec:
                        value:
                            apiVersion: vsphereprovider.openshift.io/v1beta1
                            credentialsSecret:
                                name: vsphere-cloud-credentials
                            diskGiB: <VM Disk Size>
                            kind: VSphereMachineProviderSpec
                            memoryMiB: <VM RAM Amount>
                            metadata:
                                creationTimestamp: null
                            network:
                                devices:
                                - networkName: "<VM Network Name>"
                            numCPUs: <VM CPU Amount>
                            numCoresPerSocket: 1
                            snapshot: ""
                            template: <VM Template Name>
                            userDataSecret:
                                name: worker-user-data
                            workspace:
                                datacenter: <vCenter DataCenter Name>
                                datastore: <vCenter Datastore Name>
                                folder: <Path to VM Folder in vCenter> # e.g. /DC/vm/ocp45-2tdrm
                                server: <vCenter Server FQDN/IP>

NOTE

The user specified in install-config.yaml must have the necessary permissions to deploy Virtual Machines in the vCenter instance and have the required access to the datastore specified. Refer to what are the minimum privileges required to install Openshift IPI in a vSphere environment for additional information.

  • After creating the MachineSet the new nodes will begin to provision if the replicas are set to a number other than zero.

To monitor the processes of the machine run:

$ oc get machines -w
worker-9ggp4   Provisioning                          0s
worker-9ggp4   Provisioned                           43s
worker-9ggp4   Running                               4m20s
  • Following the deployment of these Machines they will have a dynamically assigned IP Address. If the plan is to add them to the Load Balancer or have a static IP address, it will need to obtain the MAC address from vCenter and assign a fixed IP address in the DHCP server.

Root Cause

Starting in OpenShift 4.5, MachineSets are supported for VMware based clusters using the IPI and UPI installation method.
For the UPI installation additional tasks are required to utilize MachineSets.

SBR
Components

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.