Creating a compute machine set on OpenStack

You can create a different compute machine set to serve a specific purpose in your OKD cluster on OpenStack. 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 OpenStack

This sample YAML defines a compute machine set that runs on OpenStack 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> (3)
  9. namespace: openshift-machine-api
  10. spec:
  11. replicas: <number_of_replicas>
  12. selector:
  13. matchLabels:
  14. machine.openshift.io/cluster-api-cluster: <infrastructure_id> (1)
  15. machine.openshift.io/cluster-api-machineset: <infrastructure_id>-<role> (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-machine-type: <role> (2)
  22. machine.openshift.io/cluster-api-machineset: <infrastructure_id>-<role> (3)
  23. spec:
  24. providerSpec:
  25. value:
  26. apiVersion: openstackproviderconfig.openshift.io/v1alpha1
  27. cloudName: openstack
  28. cloudsSecret:
  29. name: openstack-cloud-credentials
  30. namespace: openshift-machine-api
  31. flavor: <nova_flavor>
  32. image: <glance_image_name_or_location>
  33. serverGroupID: <optional_UUID_of_server_group> (4)
  34. kind: OpenstackProviderSpec
  35. networks: (5)
  36. - filter: {}
  37. subnets:
  38. - filter:
  39. name: <subnet_name>
  40. tags: openshiftClusterID=<infrastructure_id> (1)
  41. primarySubnet: <rhosp_subnet_UUID> (6)
  42. securityGroups:
  43. - filter: {}
  44. name: <infrastructure_id>-worker (1)
  45. serverMetadata:
  46. Name: <infrastructure_id>-worker (1)
  47. openshiftClusterID: <infrastructure_id> (1)
  48. tags:
  49. - openshiftClusterID=<infrastructure_id> (1)
  50. trunk: true
  51. userDataSecret:
  52. name: worker-user-data (2)
  53. availabilityZone: <optional_openstack_availability_zone>
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 installed, you can obtain the infrastructure ID by running the following command:
  1. $ oc get -o jsonpath=’{.status.infrastructureName}{“\n”}’ infrastructure cluster
2Specify the node label to add.
3Specify the infrastructure ID and node label.
4To set a server group policy for the MachineSet, enter the value that is returned from creating a server group. For most deployments, anti-affinity or soft-anti-affinity policies are recommended.
5Required for deployments to multiple networks. To specify multiple networks, add another entry in the networks array. Also, you must include the network that is used as the primarySubnet value.
6Specify the OpenStack subnet that you want the endpoints of nodes to be published on. Usually, this is the same subnet that is used as the value of machinesSubnet in the install-config.yaml file.

Sample YAML for a compute machine set custom resource that uses SR-IOV on OpenStack

If you configured your cluster for single-root I/O virtualization (SR-IOV), you can create compute machine sets that use that technology.

This sample YAML defines a compute machine set that uses SR-IOV networks. The nodes that it creates are labeled with node-role.openshift.io/<node_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 node_role is the node label to add.

The sample assumes two SR-IOV networks that are named “radio” and “uplink”. The networks are used in port definitions in the spec.template.spec.providerSpec.value.ports list.

Only parameters that are specific to SR-IOV deployments are described in this sample. To review a more general sample, see “Sample YAML for a compute machine set custom resource on OpenStack”.

An example compute machine set that uses SR-IOV networks

  1. apiVersion: machine.openshift.io/v1beta1
  2. kind: MachineSet
  3. metadata:
  4. labels:
  5. machine.openshift.io/cluster-api-cluster: <infrastructure_id>
  6. machine.openshift.io/cluster-api-machine-role: <node_role>
  7. machine.openshift.io/cluster-api-machine-type: <node_role>
  8. name: <infrastructure_id>-<node_role>
  9. namespace: openshift-machine-api
  10. spec:
  11. replicas: <number_of_replicas>
  12. selector:
  13. matchLabels:
  14. machine.openshift.io/cluster-api-cluster: <infrastructure_id>
  15. machine.openshift.io/cluster-api-machineset: <infrastructure_id>-<node_role>
  16. template:
  17. metadata:
  18. labels:
  19. machine.openshift.io/cluster-api-cluster: <infrastructure_id>
  20. machine.openshift.io/cluster-api-machine-role: <node_role>
  21. machine.openshift.io/cluster-api-machine-type: <node_role>
  22. machine.openshift.io/cluster-api-machineset: <infrastructure_id>-<node_role>
  23. spec:
  24. metadata:
  25. providerSpec:
  26. value:
  27. apiVersion: openstackproviderconfig.openshift.io/v1alpha1
  28. cloudName: openstack
  29. cloudsSecret:
  30. name: openstack-cloud-credentials
  31. namespace: openshift-machine-api
  32. flavor: <nova_flavor>
  33. image: <glance_image_name_or_location>
  34. serverGroupID: <optional_UUID_of_server_group>
  35. kind: OpenstackProviderSpec
  36. networks:
  37. - subnets:
  38. - UUID: <machines_subnet_UUID>
  39. ports:
  40. - networkID: <radio_network_UUID> (1)
  41. nameSuffix: radio
  42. fixedIPs:
  43. - subnetID: <radio_subnet_UUID> (2)
  44. tags:
  45. - sriov
  46. - radio
  47. vnicType: direct (3)
  48. portSecurity: false (4)
  49. - networkID: <uplink_network_UUID> (1)
  50. nameSuffix: uplink
  51. fixedIPs:
  52. - subnetID: <uplink_subnet_UUID> (2)
  53. tags:
  54. - sriov
  55. - uplink
  56. vnicType: direct (3)
  57. portSecurity: false (4)
  58. primarySubnet: <machines_subnet_UUID>
  59. securityGroups:
  60. - filter: {}
  61. name: <infrastructure_id>-<node_role>
  62. serverMetadata:
  63. Name: <infrastructure_id>-<node_role>
  64. openshiftClusterID: <infrastructure_id>
  65. tags:
  66. - openshiftClusterID=<infrastructure_id>
  67. trunk: true
  68. userDataSecret:
  69. name: <node_role>-user-data
  70. availabilityZone: <optional_openstack_availability_zone>
1Enter a network UUID for each port.
2Enter a subnet UUID for each port.
3The value of the vnicType parameter must be direct for each port.
4The value of the portSecurity parameter must be false for each port.

You cannot set security groups and allowed address pairs for ports when port security is disabled. Setting security groups on the instance applies the groups to all ports that are attached to it.

After you deploy compute machines that are SR-IOV-capable, you must label them as such. For example, from a command line, enter:

  1. $ oc label node <NODE_NAME> feature.node.kubernetes.io/network-sriov.capable=”true

Trunking is enabled for ports that are created by entries in the networks and subnets lists. The names of ports that are created from these lists follow the pattern <machine_name>-<nameSuffix>. The nameSuffix field is required in port definitions.

You can enable trunking for each port.

Optionally, you can add tags to ports as part of their tags lists.

Additional resources

Sample YAML for SR-IOV deployments where port security is disabled

To create single-root I/O virtualization (SR-IOV) ports on a network that has port security disabled, define a compute machine set that includes the ports as items in the spec.template.spec.providerSpec.value.ports list. This difference from the standard SR-IOV compute machine set is due to the automatic security group and allowed address pair configuration that occurs for ports that are created by using the network and subnet interfaces.

Ports that you define for machines subnets require:

  • Allowed address pairs for the API and ingress virtual IP ports

  • The compute security group

  • Attachment to the machines network and subnet

Only parameters that are specific to SR-IOV deployments where port security is disabled are described in this sample. To review a more general sample, see Sample YAML for a compute machine set custom resource that uses SR-IOV on OpenStack”.

An example compute machine set that uses SR-IOV networks and has port security disabled

  1. apiVersion: machine.openshift.io/v1beta1
  2. kind: MachineSet
  3. metadata:
  4. labels:
  5. machine.openshift.io/cluster-api-cluster: <infrastructure_id>
  6. machine.openshift.io/cluster-api-machine-role: <node_role>
  7. machine.openshift.io/cluster-api-machine-type: <node_role>
  8. name: <infrastructure_id>-<node_role>
  9. namespace: openshift-machine-api
  10. spec:
  11. replicas: <number_of_replicas>
  12. selector:
  13. matchLabels:
  14. machine.openshift.io/cluster-api-cluster: <infrastructure_id>
  15. machine.openshift.io/cluster-api-machineset: <infrastructure_id>-<node_role>
  16. template:
  17. metadata:
  18. labels:
  19. machine.openshift.io/cluster-api-cluster: <infrastructure_id>
  20. machine.openshift.io/cluster-api-machine-role: <node_role>
  21. machine.openshift.io/cluster-api-machine-type: <node_role>
  22. machine.openshift.io/cluster-api-machineset: <infrastructure_id>-<node_role>
  23. spec:
  24. metadata: {}
  25. providerSpec:
  26. value:
  27. apiVersion: openstackproviderconfig.openshift.io/v1alpha1
  28. cloudName: openstack
  29. cloudsSecret:
  30. name: openstack-cloud-credentials
  31. namespace: openshift-machine-api
  32. flavor: <nova_flavor>
  33. image: <glance_image_name_or_location>
  34. kind: OpenstackProviderSpec
  35. ports:
  36. - allowedAddressPairs: (1)
  37. - ipAddress: <API_VIP_port_IP>
  38. - ipAddress: <ingress_VIP_port_IP>
  39. fixedIPs:
  40. - subnetID: <machines_subnet_UUID> (2)
  41. nameSuffix: nodes
  42. networkID: <machines_network_UUID> (2)
  43. securityGroups:
  44. - <compute_security_group_UUID> (3)
  45. - networkID: <SRIOV_network_UUID>
  46. nameSuffix: sriov
  47. fixedIPs:
  48. - subnetID: <SRIOV_subnet_UUID>
  49. tags:
  50. - sriov
  51. vnicType: direct
  52. portSecurity: False
  53. primarySubnet: <machines_subnet_UUID>
  54. serverMetadata:
  55. Name: <infrastructure_ID>-<node_role>
  56. openshiftClusterID: <infrastructure_id>
  57. tags:
  58. - openshiftClusterID=<infrastructure_id>
  59. trunk: false
  60. userDataSecret:
  61. name: worker-user-data
1Specify allowed address pairs for the API and ingress ports.
2Specify the machines network and subnet.
3Specify the compute machines security group.

Trunking is enabled for ports that are created by entries in the networks and subnets lists. The names of ports that are created from these lists follow the pattern <machine_name>-<nameSuffix>. The nameSuffix field is required in port definitions.

You can enable trunking for each port.

Optionally, you can add tags to ports as part of their tags lists.

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.