Creating a compute machine set on IBM Cloud

    This sample YAML defines a compute machine set that runs in a specified IBM Cloud zone in a region 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. labels:
    5. machine.openshift.io/cluster-api-cluster: <infrastructure_id> (1)
    6. machine.openshift.io/cluster-api-machine-role: <role> (2)
    7. machine.openshift.io/cluster-api-machine-type: <role> (2)
    8. name: <infrastructure_id>-<role>-<region> (3)
    9. namespace: openshift-machine-api
    10. spec:
    11. replicas: 1
    12. selector:
    13. matchLabels:
    14. machine.openshift.io/cluster-api-cluster: <infrastructure_id> (1)
    15. machine.openshift.io/cluster-api-machineset: <infrastructure_id>-<role>-<region> (3)
    16. template:
    17. metadata:
    18. labels:
    19. machine.openshift.io/cluster-api-cluster: <infrastructure_id> (1)
    20. machine.openshift.io/cluster-api-machine-role: <role> (2)
    21. machine.openshift.io/cluster-api-machineset: <infrastructure_id>-<role>-<region> (3)
    22. spec:
    23. metadata:
    24. labels:
    25. node-role.kubernetes.io/<role>: ""
    26. providerSpec:
    27. value:
    28. apiVersion: ibmcloudproviderconfig.openshift.io/v1beta1
    29. credentialsSecret:
    30. name: ibmcloud-credentials
    31. image: <infrastructure_id>-rhcos (4)
    32. kind: IBMCloudMachineProviderSpec
    33. primaryNetworkInterface:
    34. securityGroups:
    35. - <infrastructure_id>-sg-cluster-wide
    36. - <infrastructure_id>-sg-openshift-net
    37. subnet: <infrastructure_id>-subnet-compute-<zone> (5)
    38. profile: <instance_profile> (6)
    39. region: <region> (7)
    40. resourceGroup: <resource_group> (8)
    41. userDataSecret:
    42. name: <role>-user-data (2)

    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

    • 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. 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

    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