|
5 | 5 |
|
6 | 6 | :_mod-docs-content-type: PROCEDURE
|
7 | 7 | [id="machineset-modifying_{context}"]
|
8 |
| -= Modifying a compute machine set |
| 8 | += Modifying a compute machine set by using the CLI |
9 | 9 |
|
10 |
| -To make changes to a compute machine set, edit the `MachineSet` YAML. Then, remove all machines associated with the compute machine set by deleting each machine or scaling down the compute machine set to `0` replicas. Then, scale the replicas back to the desired number. Changes you make to a compute machine set do not affect existing machines. |
| 10 | +When you modify a compute machine set, your changes only apply to compute machines that are created after you save the updated `MachineSet` custom resource (CR). |
| 11 | +The changes do not affect existing machines. |
| 12 | +You can replace the existing machines with new ones that reflect the updated configuration by scaling the compute machine set. |
11 | 13 |
|
12 | 14 | If you need to scale a compute machine set without making other changes, you do not need to delete the machines.
|
13 | 15 |
|
14 | 16 | [NOTE]
|
15 | 17 | ====
|
16 |
| -By default, the {product-title} router pods are deployed on workers. Because the router is required to access some cluster resources, including the web console, do not scale the compute machine set to `0` unless you first relocate the router pods. |
| 18 | +By default, the {product-title} router pods are deployed on compute machines. |
| 19 | +Because the router is required to access some cluster resources, including the web console, do not scale the compute machine set to `0` unless you first relocate the router pods. |
17 | 20 | ====
|
18 | 21 |
|
19 | 22 | .Prerequisites
|
20 | 23 |
|
21 |
| -* Install an {product-title} cluster and the `oc` command line. |
22 |
| -* Log in to `oc` as a user with `cluster-admin` permission. |
| 24 | +* Your {product-title} cluster uses the Machine API. |
| 25 | +
|
| 26 | +* You are logged in to the cluster as an administrator by using the {oc-first}. |
23 | 27 |
|
24 | 28 | .Procedure
|
25 | 29 |
|
26 | 30 | . Edit the compute machine set by running the following command:
|
27 | 31 | +
|
28 | 32 | [source,terminal]
|
29 | 33 | ----
|
30 |
| -$ oc edit machineset <machineset> -n openshift-machine-api |
| 34 | +$ oc edit machineset <machine_set_name> -n openshift-machine-api |
31 | 35 | ----
|
32 | 36 |
|
33 |
| -. Scale down the compute machine set to `0` by running one of the following commands: |
| 37 | +. Note the value of the `spec.replicas` field, as you need it when scaling the machine set to apply the changes. |
| 38 | ++ |
| 39 | +[source,yaml] |
| 40 | +---- |
| 41 | +apiVersion: machine.openshift.io/v1beta1 |
| 42 | +kind: MachineSet |
| 43 | +metadata: |
| 44 | + name: <machine_set_name> |
| 45 | + namespace: openshift-machine-api |
| 46 | +spec: |
| 47 | + replicas: 2 # <1> |
| 48 | +# ... |
| 49 | +---- |
| 50 | +<1> The examples in this procedure show a compute machine set that has a `replicas` value of `2`. |
| 51 | + |
| 52 | +. Update the compute machine set CR with the configuration options that you want and save your changes. |
| 53 | + |
| 54 | +. List the machines that are managed by the updated compute machine set by running the following command: |
34 | 55 | +
|
35 | 56 | [source,terminal]
|
36 | 57 | ----
|
37 |
| -$ oc scale --replicas=0 machineset <machineset> -n openshift-machine-api |
| 58 | +$ oc get -n openshift-machine-api machines -l machine.openshift.io/cluster-api-machineset=<machine_set_name> |
38 | 59 | ----
|
39 | 60 | +
|
40 |
| -Or: |
| 61 | +.Example output |
| 62 | +[source,text] |
| 63 | +---- |
| 64 | +NAME PHASE TYPE REGION ZONE AGE |
| 65 | +<machine_name_original_1> Running m6i.xlarge us-west-1 us-west-1a 4h |
| 66 | +<machine_name_original_2> Running m6i.xlarge us-west-1 us-west-1a 4h |
| 67 | +---- |
| 68 | + |
| 69 | +. For each machine that is managed by the updated compute machine set, set the `delete` annotation by running the following command: |
41 | 70 | +
|
42 | 71 | [source,terminal]
|
43 | 72 | ----
|
44 |
| -$ oc edit machineset <machineset> -n openshift-machine-api |
| 73 | +$ oc annotate machine/<machine_name_original_1> \ |
| 74 | + -n openshift-machine-api \ |
| 75 | + machine.openshift.io/delete-machine="true" |
45 | 76 | ----
|
| 77 | + |
| 78 | +. Scale the compute machine set to twice the number of replicas by running the following command: |
46 | 79 | +
|
47 |
| -[TIP] |
48 |
| -==== |
49 |
| -You can alternatively apply the following YAML to scale the compute machine set: |
| 80 | +[source,terminal] |
| 81 | +---- |
| 82 | +$ oc scale --replicas=4 \// <1> |
| 83 | + machineset <machine_set_name> \ |
| 84 | + -n openshift-machine-api |
| 85 | +---- |
| 86 | +<1> The original example value of `2` is doubled to `4`. |
50 | 87 |
|
51 |
| -[source,yaml] |
| 88 | +. List the machines that are managed by the updated compute machine set by running the following command: |
| 89 | ++ |
| 90 | +[source,terminal] |
52 | 91 | ----
|
53 |
| -apiVersion: machine.openshift.io/v1beta1 |
54 |
| -kind: MachineSet |
55 |
| -metadata: |
56 |
| - name: <machineset> |
57 |
| - namespace: openshift-machine-api |
58 |
| -spec: |
59 |
| - replicas: 0 |
| 92 | +$ oc get -n openshift-machine-api machines -l machine.openshift.io/cluster-api-machineset=<machine_set_name> |
| 93 | +---- |
| 94 | ++ |
| 95 | +.Example output |
| 96 | +[source,text] |
| 97 | +---- |
| 98 | +NAME PHASE TYPE REGION ZONE AGE |
| 99 | +<machine_name_original_1> Running m6i.xlarge us-west-1 us-west-1a 4h |
| 100 | +<machine_name_original_2> Running m6i.xlarge us-west-1 us-west-1a 4h |
| 101 | +<machine_name_updated_1> Provisioned m6i.xlarge us-west-1 us-west-1a 55s |
| 102 | +<machine_name_updated_2> Provisioning m6i.xlarge us-west-1 us-west-1a 55s |
60 | 103 | ----
|
61 |
| -==== |
62 | 104 | +
|
63 |
| -Wait for the machines to be removed. |
| 105 | +When the new machines are in the `Running` phase, you can scale the compute machine set to the original number of replicas. |
64 | 106 |
|
65 |
| -. Scale up the compute machine set as needed by running one of the following commands: |
| 107 | +. Scale the compute machine set to the original number of replicas by running the following command: |
66 | 108 | +
|
67 | 109 | [source,terminal]
|
68 | 110 | ----
|
69 |
| -$ oc scale --replicas=2 machineset <machineset> -n openshift-machine-api |
| 111 | +$ oc scale --replicas=2 \// <1> |
| 112 | + machineset <machine_set_name> \ |
| 113 | + -n openshift-machine-api |
70 | 114 | ----
|
71 |
| -+ |
72 |
| -Or: |
| 115 | +<1> The original example value of `2`. |
| 116 | + |
| 117 | +.Verification |
| 118 | + |
| 119 | +* To verify that the compute machines without the updated configuration are deleted, list the machines that are managed by the updated compute machine set by running the following command: |
73 | 120 | +
|
74 | 121 | [source,terminal]
|
75 | 122 | ----
|
76 |
| -$ oc edit machineset <machineset> -n openshift-machine-api |
| 123 | +$ oc get -n openshift-machine-api machines -l machine.openshift.io/cluster-api-machineset=<machine_set_name> |
77 | 124 | ----
|
78 | 125 | +
|
79 |
| -[TIP] |
80 |
| -==== |
81 |
| -You can alternatively apply the following YAML to scale the compute machine set: |
82 |
| -
|
83 |
| -[source,yaml] |
| 126 | +.Example output while deletion is in progress |
| 127 | +[source,text] |
84 | 128 | ----
|
85 |
| -apiVersion: machine.openshift.io/v1beta1 |
86 |
| -kind: MachineSet |
87 |
| -metadata: |
88 |
| - name: <machineset> |
89 |
| - namespace: openshift-machine-api |
90 |
| -spec: |
91 |
| - replicas: 2 |
| 129 | +NAME PHASE TYPE REGION ZONE AGE |
| 130 | +<machine_name_original_1> Deleting m6i.xlarge us-west-1 us-west-1a 4h |
| 131 | +<machine_name_original_2> Deleting m6i.xlarge us-west-1 us-west-1a 4h |
| 132 | +<machine_name_updated_1> Running m6i.xlarge us-west-1 us-west-1a 5m41s |
| 133 | +<machine_name_updated_2> Running m6i.xlarge us-west-1 us-west-1a 5m41s |
92 | 134 | ----
|
93 |
| -==== |
94 | 135 | +
|
95 |
| -Wait for the machines to start. The new machines contain changes you made to the compute machine set. |
| 136 | +.Example output when deletion is complete |
| 137 | +[source,text] |
| 138 | +---- |
| 139 | +NAME PHASE TYPE REGION ZONE AGE |
| 140 | +<machine_name_updated_1> Running m6i.xlarge us-west-1 us-west-1a 6m30s |
| 141 | +<machine_name_updated_2> Running m6i.xlarge us-west-1 us-west-1a 6m30s |
| 142 | +---- |
| 143 | +
|
| 144 | +* To verify that a machine created by the updated machine set has the correct configuration, examine the relevant fields in the CR for one of the new machines by running the following command: |
| 145 | ++ |
| 146 | +[source,terminal] |
| 147 | +---- |
| 148 | +$ oc describe machine <machine_name_updated_1> -n openshift-machine-api |
| 149 | +---- |
0 commit comments