$ oc get infrastructure cluster -o jsonpath='{.status.platform}'
You can create a different compute machine set to serve a specific purpose in your OpenShift Container Platform cluster on VMware vSphere. 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 To view the platform type for your cluster, run the following command:
|
This sample YAML defines a compute machine set that runs on VMware vSphere 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.
apiVersion: machine.openshift.io/v1beta1
kind: MachineSet
metadata:
creationTimestamp: null
labels:
machine.openshift.io/cluster-api-cluster: <infrastructure_id> (1)
name: <infrastructure_id>-<role> (2)
namespace: openshift-machine-api
spec:
replicas: 1
selector:
matchLabels:
machine.openshift.io/cluster-api-cluster: <infrastructure_id> (1)
machine.openshift.io/cluster-api-machineset: <infrastructure_id>-<role> (2)
template:
metadata:
creationTimestamp: null
labels:
machine.openshift.io/cluster-api-cluster: <infrastructure_id> (1)
machine.openshift.io/cluster-api-machine-role: <role> (3)
machine.openshift.io/cluster-api-machine-type: <role> (3)
machine.openshift.io/cluster-api-machineset: <infrastructure_id>-<role> (2)
spec:
metadata:
creationTimestamp: null
labels:
node-role.kubernetes.io/<role>: "" (3)
providerSpec:
value:
apiVersion: vsphereprovider.openshift.io/v1beta1
credentialsSecret:
name: vsphere-cloud-credentials
diskGiB: 120
kind: VSphereMachineProviderSpec
memoryMiB: 8192
metadata:
creationTimestamp: null
network:
devices:
- networkName: "<vm_network_name>" (4)
numCPUs: 4
numCoresPerSocket: 1
snapshot: ""
template: <vm_template_name> (5)
userDataSecret:
name: worker-user-data
workspace:
datacenter: <vcenter_data_center_name> (6)
datastore: <vcenter_datastore_name> (7)
folder: <vcenter_vm_folder_path> (8)
resourcepool: <vsphere_resource_pool> (9)
server: <vcenter_server_ip> (10)
1 | Specify 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:
|
2 | Specify the infrastructure ID and node label. |
3 | Specify the node label to add. |
4 | Specify the vSphere VM network to deploy the compute machine set to. This VM network must be where other compute machines reside in the cluster. |
5 | Specify the vSphere VM template to use, such as user-5ddjd-rhcos . |
6 | Specify the vCenter data center to deploy the compute machine set on. |
7 | Specify the vCenter datastore to deploy the compute machine set on. |
8 | Specify the path to the vSphere VM folder in vCenter, such as /dc1/vm/user-inst-5ddjd . |
9 | Specify the vSphere resource pool for your VMs. |
10 | Specify the vCenter server IP or fully qualified domain name. |
To manage compute machine sets in an OpenShift Container Platform cluster on vCenter, you must use an account with privileges to read, create, and delete the required resources. Using an account that has global administrative privileges is the simplest way to access all of the necessary permissions.
If you cannot use an account with global administrative privileges, you must create roles to grant the minimum required privileges. The following table lists the minimum vCenter roles and privileges that are required to create, scale, and delete compute machine sets and to delete machines in your OpenShift Container Platform cluster.
vSphere object for role | When required | Required privileges |
---|---|---|
vSphere vCenter |
Always |
|
vSphere vCenter Cluster |
Always |
|
vSphere datastore |
Always |
|
vSphere Port Group |
Always |
|
Virtual Machine Folder |
Always |
|
vSphere vCenter data center |
If the installation program creates the virtual machine folder |
|
1 The |
The following table details the permissions and propagation settings that are required for compute machine set management.
vSphere object | Folder type | Propagate to children | Permissions required |
---|---|---|---|
vSphere vCenter |
Always |
Not required |
Listed required privileges |
vSphere vCenter data center |
Existing folder |
Not required |
|
Installation program creates the folder |
Required |
Listed required privileges |
|
vSphere vCenter Cluster |
Always |
Required |
Listed required privileges |
vSphere vCenter datastore |
Always |
Not required |
Listed required privileges |
vSphere Switch |
Always |
Not required |
|
vSphere Port Group |
Always |
Not required |
Listed required privileges |
vSphere vCenter Virtual Machine Folder |
Existing folder |
Required |
Listed required privileges |
For more information about creating an account with only the required privileges, see vSphere Permissions and User Management Tasks in the vSphere documentation.
To use compute machine sets on clusters that have user-provisioned infrastructure, you must ensure that you cluster configuration supports using the Machine API.
To create compute machine sets, you must be able to supply the infrastructure ID for your cluster.
To obtain the infrastructure ID for your cluster, run the following command:
$ oc get infrastructure cluster -o jsonpath='{.status.infrastructureName}'
To use compute machine sets, the Machine API must be able to interact with vCenter. Credentials that authorize the Machine API components to interact with vCenter must exist in a secret in the openshift-machine-api
namespace.
To determine whether the required credentials exist, run the following command:
$ oc get secret \
-n openshift-machine-api vsphere-cloud-credentials \
-o go-template='{{range $k,$v := .data}}{{printf "%s: " $k}}{{if not $v}}{{$v}}{{else}}{{$v | base64decode}}{{end}}{{"\n"}}{{end}}'
<vcenter-server>.password=<openshift-user-password>
<vcenter-server>.username=<openshift-user>
where <vcenter-server>
is the IP address or fully qualified domain name (FQDN) of the vCenter server and <openshift-user>
and <openshift-user-password>
are the OpenShift Container Platform administrator credentials to use.
If the secret does not exist, create it by running the following command:
$ oc create secret generic vsphere-cloud-credentials \
-n openshift-machine-api \
--from-literal=<vcenter-server>.username=<openshift-user> --from-literal=<vcenter-server>.password=<openshift-user-password>
Provisioning virtual machines (VMs) requires a valid Ignition configuration. The Ignition configuration contains the machine-config-server
address and a system trust bundle for obtaining further Ignition configurations from the Machine Config Operator.
By default, this configuration is stored in the worker-user-data
secret in the machine-api-operator
namespace. Compute machine sets reference the secret during the machine creation process.
To determine whether the required secret exists, run the following command:
$ oc get secret \
-n openshift-machine-api worker-user-data \
-o go-template='{{range $k,$v := .data}}{{printf "%s: " $k}}{{if not $v}}{{$v}}{{else}}{{$v | base64decode}}{{end}}{{"\n"}}{{end}}'
disableTemplating: false
userData: (1)
{
"ignition": {
...
},
...
}
1 | The full output is omitted here, but should have this format. |
If the secret does not exist, create it by running the following command:
$ oc create secret generic worker-user-data \
-n openshift-machine-api \
--from-file=<installation_directory>/worker.ign
where <installation_directory>
is the directory that was used to store your installation assets during cluster installation.
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.
Clusters that are installed with user-provisioned infrastructure have a different networking stack than clusters with infrastructure that is provisioned by the installation program. As a result of this difference, automatic load balancer management is unsupported on clusters that have user-provisioned infrastructure. For these clusters, a compute machine set can only create |
Deploy an OpenShift Container Platform cluster.
Install the OpenShift CLI (oc
).
Log in to oc
as a user with cluster-admin
permission.
Have the necessary permissions to deploy VMs in your vCenter instance and have the required access to the datastore specified.
If your cluster uses user-provisioned infrastructure, you have satisfied the specific Machine API requirements for that configuration.
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.
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.
To list the compute machine sets in your cluster, run the following command:
$ oc get machinesets -n openshift-machine-api
NAME DESIRED CURRENT READY AVAILABLE AGE
agl030519-vplxk-worker-us-east-1a 1 1 1 1 55m
agl030519-vplxk-worker-us-east-1b 1 1 1 1 55m
agl030519-vplxk-worker-us-east-1c 1 1 1 1 55m
agl030519-vplxk-worker-us-east-1d 0 0 55m
agl030519-vplxk-worker-us-east-1e 0 0 55m
agl030519-vplxk-worker-us-east-1f 0 0 55m
To view values of a specific compute machine set custom resource (CR), run the following command:
$ oc get machineset <machineset_name> \
-n openshift-machine-api -o yaml
apiVersion: machine.openshift.io/v1beta1
kind: MachineSet
metadata:
labels:
machine.openshift.io/cluster-api-cluster: <infrastructure_id> (1)
name: <infrastructure_id>-<role> (2)
namespace: openshift-machine-api
spec:
replicas: 1
selector:
matchLabels:
machine.openshift.io/cluster-api-cluster: <infrastructure_id>
machine.openshift.io/cluster-api-machineset: <infrastructure_id>-<role>
template:
metadata:
labels:
machine.openshift.io/cluster-api-cluster: <infrastructure_id>
machine.openshift.io/cluster-api-machine-role: <role>
machine.openshift.io/cluster-api-machine-type: <role>
machine.openshift.io/cluster-api-machineset: <infrastructure_id>-<role>
spec:
providerSpec: (3)
...
1 | The cluster infrastructure ID. | ||
2 | A default node label.
|
||
3 | The 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. |
If you are creating a compute machine set for a cluster that has user-provisioned infrastructure, note the following important values:
providerSpec
valuesapiVersion: machine.openshift.io/v1beta1
kind: MachineSet
...
template:
...
spec:
providerSpec:
value:
apiVersion: machine.openshift.io/v1beta1
credentialsSecret:
name: vsphere-cloud-credentials (1)
diskGiB: 120
kind: VSphereMachineProviderSpec
memoryMiB: 16384
network:
devices:
- networkName: "<vm_network_name>"
numCPUs: 4
numCoresPerSocket: 4
snapshot: ""
template: <vm_template_name> (2)
userDataSecret:
name: worker-user-data (3)
workspace:
datacenter: <vcenter_data_center_name>
datastore: <vcenter_datastore_name>
folder: <vcenter_vm_folder_path>
resourcepool: <vsphere_resource_pool>
server: <vcenter_server_address> (4)
1 | The name of the secret in the openshift-machine-api namespace that contains the required vCenter credentials. |
2 | The name of the RHCOS VM template for your cluster that was created during installation. |
3 | The name of the secret in the openshift-machine-api namespace that contains the required Ignition configuration credentials. |
4 | The IP address or fully qualified domain name (FQDN) of the vCenter server. |
Create a MachineSet
CR by running the following command:
$ oc create -f <file_name>.yaml
View the list of compute machine sets by running the following command:
$ oc get machineset -n openshift-machine-api
NAME DESIRED CURRENT READY AVAILABLE AGE
agl030519-vplxk-infra-us-east-1a 1 1 1 1 11m
agl030519-vplxk-worker-us-east-1a 1 1 1 1 55m
agl030519-vplxk-worker-us-east-1b 1 1 1 1 55m
agl030519-vplxk-worker-us-east-1c 1 1 1 1 55m
agl030519-vplxk-worker-us-east-1d 0 0 55m
agl030519-vplxk-worker-us-east-1e 0 0 55m
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.
OpenShift Container Platform adds a cluster-specific tag to each virtual machine (VM) that it creates. The installation program uses these tags to select the VMs to delete when uninstalling a cluster.
In addition to the cluster-specific tags assigned to VMs, you can configure a machine set to add up to 10 additional vSphere tags to the VMs it provisions.
You have access to an OpenShift Container Platform cluster installed on vSphere using an account with cluster-admin
permissions.
You have access to the VMware vCenter console associated with your cluster.
You have created a tag in the vCenter console.
You have installed the OpenShift CLI (oc
).
Use the vCenter console to find the tag ID for any tag that you want to add to your machines:
Log in to the vCenter console.
From the Home menu, click Tags & Custom Attributes.
Select a tag that you want to add to your machines.
Use the browser URL for the tag that you select to identify the tag ID.
https://vcenter.example.com/ui/app/tags/tag/urn:vmomi:InventoryServiceTag:208e713c-cae3-4b7f-918e-4051ca7d1f97:GLOBAL/permissions
urn:vmomi:InventoryServiceTag:208e713c-cae3-4b7f-918e-4051ca7d1f97:GLOBAL
In a text editor, open the YAML file for an existing machine set or create a new one.
Edit the following lines under the providerSpec
field:
apiVersion: machine.openshift.io/v1beta1
kind: MachineSet
# ...
spec:
template:
spec:
providerSpec:
value:
tagIDs: (1)
- <tag_id_value> (2)
# ...
1 | Specify a list of up to 10 tags to add to the machines that this machine set provisions. |
2 | Specify the value of the tag that you want to add to your machines.
For example, urn:vmomi:InventoryServiceTag:208e713c-cae3-4b7f-918e-4051ca7d1f97:GLOBAL . |