Creating a compute machine set on bare metal

You can create a different compute machine set to serve a specific purpose in your OKD cluster on bare metal. For example, you might create infrastructure machine sets and related machines so that you can move supporting workloads to the new machines.

You can use the advanced machine management and scaling capabilities only in clusters where the Machine API is operational. Clusters with user-provisioned infrastructure require additional validation and configuration to use the Machine API.

Clusters with the infrastructure platform type none cannot use the Machine API. This limitation applies even if the compute machines that are attached to the cluster are installed on a platform that supports the feature. This parameter cannot be changed after installation.

To view the platform type for your cluster, run the following command:

  1. $ oc get infrastructure cluster -o jsonpath=’{.status.platform}’

Sample YAML for a compute machine set custom resource on bare metal

This sample YAML defines a compute machine set that runs on bare metal and creates nodes that are labeled with node-role.kubernetes.io/<role>: "".

In this sample, <infrastructure_id> is the infrastructure ID label that is based on the cluster ID that you set when you provisioned the cluster, and <role> is the node label to add.

  1. apiVersion: machine.openshift.io/v1beta1
  2. kind: MachineSet
  3. metadata:
  4. creationTimestamp: null
  5. labels:
  6. machine.openshift.io/cluster-api-cluster: <infrastructure_id> (1)
  7. name: <infrastructure_id>-<role> (2)
  8. namespace: openshift-machine-api
  9. spec:
  10. replicas: 1
  11. selector:
  12. matchLabels:
  13. machine.openshift.io/cluster-api-cluster: <infrastructure_id> (1)
  14. machine.openshift.io/cluster-api-machineset: <infrastructure_id>-<role> (2)
  15. template:
  16. metadata:
  17. creationTimestamp: null
  18. labels:
  19. machine.openshift.io/cluster-api-cluster: <infrastructure_id> (1)
  20. machine.openshift.io/cluster-api-machine-role: <role> (3)
  21. machine.openshift.io/cluster-api-machine-type: <role> (3)
  22. machine.openshift.io/cluster-api-machineset: <infrastructure_id>-<role> (2)
  23. spec:
  24. metadata:
  25. creationTimestamp: null
  26. labels:
  27. node-role.kubernetes.io/<role>: "" (3)
  28. providerSpec:
  29. value:
  30. apiVersion: baremetal.cluster.k8s.io/v1alpha1
  31. hostSelector: {}
  32. image:
  33. checksum: http:/172.22.0.3:6181/images/rhcos-<version>.<architecture>.qcow2.<md5sum> (4)
  34. url: http://172.22.0.3:6181/images/rhcos-<version>.<architecture>.qcow2 (5)
  35. kind: BareMetalMachineProviderSpec
  36. metadata:
  37. creationTimestamp: null
  38. userData:
  39. name: worker-user-data
1Specify the infrastructure ID that is based on the cluster ID that you set when you provisioned the cluster. If you have the OpenShift CLI (oc) installed, you can obtain the infrastructure ID by running the following command:
  1. $ oc get -o jsonpath=’{.status.infrastructureName}{“\n”}’ infrastructure cluster
2Specify the infrastructure ID and node label.
3Specify the node label to add.
4Edit the checksum URL to use the API VIP address.
5Edit the url URL to use the API VIP address.

Creating a compute machine set

In addition to the compute machine sets created by the installation program, you can create your own to dynamically manage the machine compute resources for specific workloads of your choice.

Prerequisites

  • Deploy an OKD cluster.

  • Install the OpenShift CLI (oc).

  • Log in to oc as a user with cluster-admin permission.

Procedure

  1. Create a new YAML file that contains the compute machine set custom resource (CR) sample and is named <file_name>.yaml.

    Ensure that you set the <clusterID> and <role> parameter values.

  2. Optional: If you are not sure which value to set for a specific field, you can check an existing compute machine set from your cluster.

    1. To list the compute machine sets in your cluster, run the following command:

      1. $ oc get machinesets -n openshift-machine-api

      Example output

      1. NAME DESIRED CURRENT READY AVAILABLE AGE
      2. agl030519-vplxk-worker-us-east-1a 1 1 1 1 55m
      3. agl030519-vplxk-worker-us-east-1b 1 1 1 1 55m
      4. agl030519-vplxk-worker-us-east-1c 1 1 1 1 55m
      5. agl030519-vplxk-worker-us-east-1d 0 0 55m
      6. agl030519-vplxk-worker-us-east-1e 0 0 55m
      7. agl030519-vplxk-worker-us-east-1f 0 0 55m
    2. To view values of a specific compute machine set custom resource (CR), run the following command:

      1. $ oc get machineset <machineset_name> \
      2. -n openshift-machine-api -o yaml

      Example output

      1. apiVersion: machine.openshift.io/v1beta1
      2. kind: MachineSet
      3. metadata:
      4. labels:
      5. machine.openshift.io/cluster-api-cluster: <infrastructure_id> (1)
      6. name: <infrastructure_id>-<role> (2)
      7. namespace: openshift-machine-api
      8. spec:
      9. replicas: 1
      10. selector:
      11. matchLabels:
      12. machine.openshift.io/cluster-api-cluster: <infrastructure_id>
      13. machine.openshift.io/cluster-api-machineset: <infrastructure_id>-<role>
      14. template:
      15. metadata:
      16. labels:
      17. machine.openshift.io/cluster-api-cluster: <infrastructure_id>
      18. machine.openshift.io/cluster-api-machine-role: <role>
      19. machine.openshift.io/cluster-api-machine-type: <role>
      20. machine.openshift.io/cluster-api-machineset: <infrastructure_id>-<role>
      21. spec:
      22. providerSpec: (3)
      23. ...
      1The cluster infrastructure ID.
      2A default node label.

      For clusters that have user-provisioned infrastructure, a compute machine set can only create worker and infra type machines.

      3The values in the <providerSpec> section of the compute machine set CR are platform-specific. For more information about <providerSpec> parameters in the CR, see the sample compute machine set CR configuration for your provider.
  3. Create a MachineSet CR by running the following command:

    1. $ oc create -f <file_name>.yaml

Verification

  • View the list of compute machine sets by running the following command:

    1. $ oc get machineset -n openshift-machine-api

    Example output

    1. NAME DESIRED CURRENT READY AVAILABLE AGE
    2. agl030519-vplxk-infra-us-east-1a 1 1 1 1 11m
    3. agl030519-vplxk-worker-us-east-1a 1 1 1 1 55m
    4. agl030519-vplxk-worker-us-east-1b 1 1 1 1 55m
    5. agl030519-vplxk-worker-us-east-1c 1 1 1 1 55m
    6. agl030519-vplxk-worker-us-east-1d 0 0 55m
    7. agl030519-vplxk-worker-us-east-1e 0 0 55m
    8. agl030519-vplxk-worker-us-east-1f 0 0 55m

    When the new compute machine set is available, the DESIRED and CURRENT values match. If the compute machine set is not available, wait a few minutes and run the command again.