|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * machine_management/capi-machine-management.adoc |
| 4 | + |
| 5 | +:_content-type: PROCEDURE |
| 6 | +[id="capi-machine-set-creating_{context}"] |
| 7 | += Creating a Cluster API machine set |
| 8 | + |
| 9 | +You can create machine sets that use the Cluster API to dynamically manage the machine compute resources for specific workloads of your choice. |
| 10 | + |
| 11 | +.Prerequisites |
| 12 | + |
| 13 | +* Deploy an {product-title} cluster. |
| 14 | +* Enable the use of the Cluster API. |
| 15 | +* Install the OpenShift CLI (`oc`). |
| 16 | +* Log in to `oc` as a user with `cluster-admin` permission. |
| 17 | +
|
| 18 | +.Procedure |
| 19 | + |
| 20 | +. Create a YAML file that contains the cluster custom resource (CR) and is named `<cluster_resource_file>.yaml`. |
| 21 | ++ |
| 22 | +If you are not sure which value to set for the `<cluster_name>` parameter, you can check the value for an existing Machine API machine set in your cluster. |
| 23 | + |
| 24 | +.. To list the Machine API machine sets, run the following command: |
| 25 | ++ |
| 26 | +[source,terminal] |
| 27 | +---- |
| 28 | +$ oc get machinesets -n openshift-machine-api <1> |
| 29 | +---- |
| 30 | +<1> Specify the `openshift-machine-api` namespace. |
| 31 | ++ |
| 32 | +.Example output |
| 33 | +[source,terminal] |
| 34 | +---- |
| 35 | +NAME DESIRED CURRENT READY AVAILABLE AGE |
| 36 | +agl030519-vplxk-worker-us-east-1a 1 1 1 1 55m |
| 37 | +agl030519-vplxk-worker-us-east-1b 1 1 1 1 55m |
| 38 | +agl030519-vplxk-worker-us-east-1c 1 1 1 1 55m |
| 39 | +agl030519-vplxk-worker-us-east-1d 0 0 55m |
| 40 | +agl030519-vplxk-worker-us-east-1e 0 0 55m |
| 41 | +agl030519-vplxk-worker-us-east-1f 0 0 55m |
| 42 | +---- |
| 43 | + |
| 44 | +.. To display the contents of a specific machine set CR, run the following command: |
| 45 | ++ |
| 46 | +[source,terminal] |
| 47 | +---- |
| 48 | +$ oc get machineset <machineset_name> \ |
| 49 | +-n openshift-machine-api \ |
| 50 | +-o yaml |
| 51 | +---- |
| 52 | ++ |
| 53 | +.Example output |
| 54 | +[source,yaml] |
| 55 | +---- |
| 56 | +... |
| 57 | +template: |
| 58 | + metadata: |
| 59 | + labels: |
| 60 | + machine.openshift.io/cluster-api-cluster: agl030519-vplxk <1> |
| 61 | + machine.openshift.io/cluster-api-machine-role: worker |
| 62 | + machine.openshift.io/cluster-api-machine-type: worker |
| 63 | + machine.openshift.io/cluster-api-machineset: agl030519-vplxk-worker-us-east-1a |
| 64 | +... |
| 65 | +---- |
| 66 | +<1> The cluster ID, which you use for the `<cluster_name>` parameter. |
| 67 | + |
| 68 | +. Create the cluster CR by running the following command: |
| 69 | ++ |
| 70 | +[source,terminal] |
| 71 | +---- |
| 72 | +$ oc create -f <cluster_resource_file>.yaml |
| 73 | +---- |
| 74 | ++ |
| 75 | +.Verification |
| 76 | ++ |
| 77 | +To confirm that the cluster CR is created, run the following command: |
| 78 | ++ |
| 79 | +[source,terminal] |
| 80 | +---- |
| 81 | +$ oc get cluster |
| 82 | +---- |
| 83 | ++ |
| 84 | +.Example output |
| 85 | +[source,terminal] |
| 86 | +---- |
| 87 | +NAME PHASE AGE VERSION |
| 88 | +<cluster_name> Provisioning 4h6m |
| 89 | +---- |
| 90 | + |
| 91 | +. Create a YAML file that contains the infrastructure CR and is named `<infrastructure_resource_file>.yaml`. |
| 92 | + |
| 93 | +. Create the infrastructure CR by running the following command: |
| 94 | ++ |
| 95 | +[source,terminal] |
| 96 | +---- |
| 97 | +$ oc create -f <infrastructure_resource_file>.yaml |
| 98 | +---- |
| 99 | ++ |
| 100 | +.Verification |
| 101 | ++ |
| 102 | +To confirm that the infrastructure CR is created, run the following command: |
| 103 | ++ |
| 104 | +[source,terminal] |
| 105 | +---- |
| 106 | +$ oc get <infrastructure_kind> |
| 107 | +---- |
| 108 | ++ |
| 109 | +where `<infrastructure_kind>` is the value that corresponds to your platform. |
| 110 | ++ |
| 111 | +.Example output |
| 112 | +[source,terminal] |
| 113 | +---- |
| 114 | +NAME CLUSTER READY VPC BASTION IP |
| 115 | +<cluster_name> <cluster_name> true |
| 116 | +---- |
| 117 | + |
| 118 | +. Create a YAML file that contains the machine template CR and is named `<machine_template_resource_file>.yaml`. |
| 119 | + |
| 120 | +. Create the machine template CR by running the following command: |
| 121 | ++ |
| 122 | +[source,terminal] |
| 123 | +---- |
| 124 | +$ oc create -f <machine_template_resource_file>.yaml |
| 125 | +---- |
| 126 | ++ |
| 127 | +.Verification |
| 128 | ++ |
| 129 | +To confirm that the machine template CR is created, run the following command: |
| 130 | ++ |
| 131 | +[source,terminal] |
| 132 | +---- |
| 133 | +$ oc get <machine_template_kind> |
| 134 | +---- |
| 135 | ++ |
| 136 | +where `<machine_template_kind>` is the value that corresponds to your platform. |
| 137 | ++ |
| 138 | +.Example output |
| 139 | +[source,terminal] |
| 140 | +---- |
| 141 | +NAME AGE |
| 142 | +<template_name> 77m |
| 143 | +---- |
| 144 | + |
| 145 | +. Create a YAML file that contains the machine set CR and is named `<machine_set_resource_file>.yaml`. |
| 146 | + |
| 147 | +. Create the machine set CR by running the following command: |
| 148 | ++ |
| 149 | +[source,terminal] |
| 150 | +---- |
| 151 | +$ oc create -f <machine_set_resource_file>.yaml |
| 152 | +---- |
| 153 | ++ |
| 154 | +.Verification |
| 155 | ++ |
| 156 | +To confirm that the machine set CR is created, run the following command: |
| 157 | ++ |
| 158 | +[source,terminal] |
| 159 | +---- |
| 160 | +$ oc get machineset -n openshift-cluster-api <1> |
| 161 | +---- |
| 162 | +<1> Specify the `openshift-cluster-api` namespace. |
| 163 | ++ |
| 164 | +.Example output |
| 165 | +[source,terminal] |
| 166 | +---- |
| 167 | +NAME CLUSTER REPLICAS READY AVAILABLE AGE VERSION |
| 168 | +<machine_set_name> <cluster_name> 1 1 1 17m |
| 169 | +---- |
| 170 | ++ |
| 171 | +When the new machine set is available, the `REPLICAS` and `AVAILABLE` values match. If the machine set is not available, wait a few minutes and run the command again. |
| 172 | + |
| 173 | +.Verification |
| 174 | + |
| 175 | +* To verify that the machine set is creating machines according to your desired configuration, you can review the lists of machines and nodes in the cluster. |
| 176 | +
|
| 177 | +** To view the list of Cluster API machines, run the following command: |
| 178 | ++ |
| 179 | +[source,terminal] |
| 180 | +---- |
| 181 | +$ oc get machine -n openshift-cluster-api <1> |
| 182 | +---- |
| 183 | +<1> Specify the `openshift-cluster-api` namespace. |
| 184 | ++ |
| 185 | +.Example output |
| 186 | +[source,terminal] |
| 187 | +---- |
| 188 | +NAME CLUSTER NODENAME PROVIDERID PHASE AGE VERSION |
| 189 | +<machine_set_name>-<string_id> <cluster_name> <ip_address>.<region>.compute.internal <provider_id> Running 8m23s |
| 190 | +---- |
| 191 | + |
| 192 | +** To view the list of nodes, run the following command: |
| 193 | ++ |
| 194 | +[source,terminal] |
| 195 | +---- |
| 196 | +$ oc get node |
| 197 | +---- |
| 198 | ++ |
| 199 | +.Example output |
| 200 | +[source,terminal] |
| 201 | +---- |
| 202 | +NAME STATUS ROLES AGE VERSION |
| 203 | +<ip_address_1>.<region>.compute.internal Ready worker 5h14m v1.24.0+284d62a |
| 204 | +<ip_address_2>.<region>.compute.internal Ready master 5h19m v1.24.0+284d62a |
| 205 | +<ip_address_3>.<region>.compute.internal Ready worker 7m v1.24.0+284d62a |
| 206 | +---- |
0 commit comments