このコンテンツは選択した言語では利用できません。

Chapter 4. Modifying a compute machine set


To add labels, change the instance type, change block storage, or make other changes, you can modify a compute machine set.

Note

If you need to scale a compute machine set without making other changes, see "Manually scaling a compute machine set".

4.1. Modifying a compute machine set by using the CLI

To enable features or change the properties of machines, you can modify the configuration of a compute machine set using the CLI. You can then propagate the changes to the machines in your cluster.

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). The changes do not affect existing machines.

Note

Changes made in the underlying cloud provider are not reflected in the Machine or MachineSet CRs. To adjust instance configuration in cluster-managed infrastructure, use the cluster-side resources.

You can replace the existing machines with new ones that reflect the updated configuration by scaling the compute machine set to create twice the number of replicas and then scaling it down to the original number of replicas.

If you need to scale a compute machine set without making other changes, you do not need to delete the machines.

Note

By default, the OpenShift Container Platform router pods are deployed on compute machines. 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.

The output examples in this procedure use the values for an AWS cluster.

Prerequisites

  • Your OpenShift Container Platform cluster uses the Machine API.
  • You are logged in to the cluster as an administrator by using the OpenShift CLI (oc).

Procedure

  1. List the compute machine sets in your cluster by running the following command:

    $ oc get machinesets.machine.openshift.io -n openshift-machine-api

    Example output

    NAME                           DESIRED   CURRENT   READY   AVAILABLE   AGE
    <compute_machine_set_name_1>   1         1         1       1           55m
    <compute_machine_set_name_2>   1         1         1       1           55m

  2. Edit a compute machine set by running the following command:

    $ oc edit machinesets.machine.openshift.io <machine_set_name> \
      -n openshift-machine-api
  3. Note the value of the spec.replicas field, because you need it when scaling the machine set to apply the changes.

    apiVersion: machine.openshift.io/v1beta1
    kind: MachineSet
    metadata:
      name: <machine_set_name>
      namespace: openshift-machine-api
    spec:
      replicas: 2
    # ...

    The examples in this procedure show a compute machine set that has a replicas value of 2.

  4. Update the compute machine set CR with the configuration options that you want and save your changes.
  5. List the machines that are managed by the updated compute machine set by running the following command:

    $ oc get machines.machine.openshift.io \
      -n openshift-machine-api \
      -l machine.openshift.io/cluster-api-machineset=<machine_set_name>

    Example output for an AWS cluster

    NAME                        PHASE     TYPE         REGION      ZONE         AGE
    <machine_name_original_1>   Running   m6i.xlarge   us-west-1   us-west-1a   4h
    <machine_name_original_2>   Running   m6i.xlarge   us-west-1   us-west-1a   4h

  6. For each machine that is managed by the updated compute machine set, set the delete annotation by running the following command:

    $ oc annotate machine.machine.openshift.io/<machine_name_original_1> \
      -n openshift-machine-api \
      machine.openshift.io/delete-machine="true"
  7. To create replacement machines with the new configuration, scale the compute machine set to twice the number of replicas by running the following command:

    $ oc scale --replicas=4 \
      machineset.machine.openshift.io <machine_set_name> \
      -n openshift-machine-api

    The original example value of 2 is doubled to 4.

  8. List the machines that are managed by the updated compute machine set by running the following command:

    $ oc get machines.machine.openshift.io \
      -n openshift-machine-api \
      -l machine.openshift.io/cluster-api-machineset=<machine_set_name>

    Example output for an AWS cluster

    NAME                        PHASE          TYPE         REGION      ZONE         AGE
    <machine_name_original_1>   Running        m6i.xlarge   us-west-1   us-west-1a   4h
    <machine_name_original_2>   Running        m6i.xlarge   us-west-1   us-west-1a   4h
    <machine_name_updated_1>    Provisioned    m6i.xlarge   us-west-1   us-west-1a   55s
    <machine_name_updated_2>    Provisioning   m6i.xlarge   us-west-1   us-west-1a   55s

    When the new machines are in the Running phase, you can scale the compute machine set to the original number of replicas.

  9. To remove the machines that were created with the old configuration, scale the compute machine set to the original number of replicas by running the following command:

    $ oc scale --replicas=2 \
      machineset.machine.openshift.io <machine_set_name> \
      -n openshift-machine-api

    The replicas parameter is set to the original example value of 2.

Verification

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

    $ oc describe machine.machine.openshift.io <machine_name_updated_1> \
      -n openshift-machine-api
  • 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:

    $ oc get machines.machine.openshift.io \
      -n openshift-machine-api \
      -l machine.openshift.io/cluster-api-machineset=<machine_set_name>

    Example output while deletion is in progress for an AWS cluster

    NAME                        PHASE           TYPE         REGION      ZONE         AGE
    <machine_name_original_1>   Deleting        m6i.xlarge   us-west-1   us-west-1a   4h
    <machine_name_original_2>   Deleting        m6i.xlarge   us-west-1   us-west-1a   4h
    <machine_name_updated_1>    Running         m6i.xlarge   us-west-1   us-west-1a   5m41s
    <machine_name_updated_2>    Running         m6i.xlarge   us-west-1   us-west-1a   5m41s

    Example output when deletion is complete for an AWS cluster

    NAME                        PHASE           TYPE         REGION      ZONE         AGE
    <machine_name_updated_1>    Running         m6i.xlarge   us-west-1   us-west-1a   6m30s
    <machine_name_updated_2>    Running         m6i.xlarge   us-west-1   us-west-1a   6m30s

    end::MAPI[]

Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2026 Red Hat
トップに戻る