VM プロパティを更新する

このページでは、既存の VM で更新できる仮想マシン(VM)のプロパティと、そのような更新を行う方法について説明します。

始める前に

gdcloud コマンドライン インターフェース(CLI)コマンドを使用するには、gdcloud CLI をダウンロード、インストール、構成していることを確認してください。Distributed Cloud のすべてのコマンドは gdcloud または kubectl CLI を使用し、オペレーティング システム(OS)環境が必要です。

kubeconfig ファイルのパスを取得する

Management API サーバーに対してコマンドを実行するには、次のリソースがあることを確認します。

  1. Management API サーバーの kubeconfig ファイルがない場合は、ログインして生成します。

  2. これらの手順では、Management API サーバーの kubeconfig ファイルのパスを使用して MANAGEMENT_API_SERVER を置き換えます。

権限とアクセス権をリクエストする

このページに記載されているタスクを行うには、プロジェクトの VirtualMachine 管理者ロールが必要です。VM が存在するプロジェクトの名前空間にプロジェクト VirtualMachine 管理者(project-vm-admin)ロールがあることを確認する手順に沿って操作します。

GDC コンソールまたは gdcloud CLI を使用する VM オペレーションの場合は、プロジェクト IAM 管理者に、プロジェクトの VirtualMachine 管理者ロールとプロジェクト閲覧者(project-viewer)ロールの両方を割り当てるよう依頼します。

更新可能なプロパティ

変更できるのは、VM の spec にあるプロパティのみです。

更新可能なプロパティを表示する

GDC コンソールまたは kubectl を使用して、変更するプロパティを見つけます。

コンソール

  1. ナビゲーション メニューで、[仮想マシン] > [インスタンス] をクリックします。

  2. VM のリストで、VM 名をクリックしてプロパティを表示します。

  3. 編集可能なプロパティには、編集)アイコンが表示されます。

kubectl

  1. VM spec のプロパティのリストと、各プロパティに対応する有効な値を表示します。

    kubectl --kubeconfig MANAGEMENT_API_SERVER explain virtualmachines.virtualmachine.gdc.goog.spec
    

    出力は次のようになります。

    KIND:     VirtualMachine
    VERSION:  virtualmachine.gdc.goog/v1
    
    RESOURCE: spec <Object>
    
    DESCRIPTION:
         Defines the specification of the Virtual Machine.
    
    FIELDS:
       compute      <Object>
         Specifies the CPU and Memory of the VM. CPU and Memory can be defined
         directly or through the VirtualMachineType. Changes to Compute require a
         reboot to take effect. Compute is immutable when the VM is in `Unknown`
         state.
    
       disks        <[]Object> -required-
         Specifies the list of disks attached to this vm. There must be exactly one
         boot disk. Changes to disk attachments require a reboot to take effect.
    
       ...
    
  2. 各プロパティのサブプロパティを再帰的に表示します。次の例は、computevcpus のサブプロパティの戻り値を示しています。

    • このコマンド例は、compute サブプロパティのフィールドを返します。

      kubectl --kubeconfig MANAGEMENT_API_SERVER explain virtualmachines.virtualmachine.gdc.goog.spec.compute
      

      出力は次のようになります。

      KIND:     VirtualMachine
      VERSION:  virtualmachine.gdc.goog/v1
      
      RESOURCE: compute <Object>
      
      DESCRIPTION:
           Specifies the CPU and Memory of the VM. CPU and Memory can be defined
           directly or through the VirtualMachineType. Changes to Compute require a
           reboot to take effect. Compute is immutable when the VM is in `Unknown`
           state.
      
      FIELDS:
         memory       <>
           Specifies the amount of physical memory available to the instance. memory
           must have a minimum value of `1G`, and can be up to (including) `400G`.
      
         vcpus        <integer>
           Specifies the number of VCPUs that are available to the instance. Specify
           `vcpus` as an integer. This value must be a multiple of 2, with 2 as the
           minimum and 128 as the maximum allowed.
      
         ...
      
    • このコマンド例は、vcpus サブプロパティのフィールドを返します。

      kubectl --kubeconfig MANAGEMENT_API_SERVER explain virtualmachines.virtualmachine.gdc.goog.spec.compute.vcpus
      

      出力は次のようになります。

      KIND:     VirtualMachine
      VERSION:  virtualmachine.gdc.goog/v1
      
      FIELD:    vcpus <integer>
      
      DESCRIPTION:
           Specifies the number of VCPUs that are available to the instance. Specify
           `vcpus` as an integer. This value must be a multiple of 2, with 2 as the
           minimum and 128 as the maximum allowed.
      

すべてのプロパティは実行中の VM で更新できますが、多くの場合、変更を有効にするには VM の再起動が必要です。

これらのプロパティの更新を有効にするには、VM を再起動する必要があります。

これらのプロパティの更新はすぐに有効になります。

  • guestEnvironment
  • runningState

VM プロパティを更新する

VM のプロパティを更新するには、GDC コンソールまたは kubectl を使用します。

コンソール

  1. ナビゲーション メニューで、[仮想マシン] > [インスタンス] をクリックします。

  2. VM のリストで、VM 名をクリックしてプロパティを表示します。

  3. 編集するプロパティの横にある [ 編集] をクリックして、変更を加えます。

  4. ブートディスクを置き換えるか、新しいディスクを追加する場合は、ブートディスクを置き換えるまたは VM にディスクを追加するをご覧ください。

  5. [保存] をクリックします。

kubectl

  1. 次のコマンドを実行します。

    kubectl --kubeconfig MANAGEMENT_API_SERVER \
       edit virtualmachines.virtualmachine.gdc.goog VM_NAME \
       -n PROJECT
    

    次の表で定義されている変数に置き換えます。

    変数定義
    MANAGEMENT_API_SERVERManagement API サーバーの kubeconfig ファイル。
    VM_NAMEVM の名前。
    PROJECTプロジェクト名。
  2. spec を編集して、更新可能なプロパティの必須フィールドと値を更新します。

  3. ファイルを保存します。

  4. プロパティの更新で VM の再起動が必要な場合は、VM を再起動するの手順に沿って VM を再起動します。