0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

OpenShift Virtualization (OCP-V) - Edit VM - Memory

Last updated at Posted at 2025-04-25

OpenShift Virtualization

Red Hat® OpenShift® Virtualization は Red Hat OpenShift に含まれる機能であり、組織が新規および既存の仮想マシン (VM) ワークロードを実行およびデプロイするための先進的なプラットフォームを提供します。このソリューションにより、従来の仮想マシンを、信頼できる、一貫した包括的なハイブリッドクラウド・アプリケーション・プラットフォームに簡単に移行できます。

OpenShift Virtualization は、VM の移行を単純化するとともに、クラウドネイティブ・アプリケーション・プラットフォームのシンプルさと速度を利用してインフラストラクチャのモダナイゼーションの道筋を提供します。また、先進的な管理の原則を取り入れつつ既存の仮想化への投資を維持することを目指しており、Red Hat の包括的な仮想化ソリューションの基盤となります。

Edit VM

OCP 4.17 Bare Metal 環境 OpenShift Virtualization (OCP-V) で Virtual Machine (VM) を編集してみます。ここでは以下の手順を参考に、作成済み VM を編集します。

Editing virtual machines

Memory

OCP Console から VM 再起動無しで動的に Memory 構成の変更をする事が出来ますが、変更反映時に Live Migration が行われます。また、手動での VM 再起動が必要なものもあります。

Hot plugging memory on a virtual machine

この機能を使用するには、以下の前提条件を満たす必要があります。

Linux guests require a kernel version of 5.16 or later and Windows guests require the latest viomem drivers.

OCP Console
Live Migration 可能な VM
Add Memory

以下の VM を編集してみます。この VM は Live Migration 可能な状態で worker02 で稼働しています。

image.png

$ oc get pod,vmi,vm -o wide
NAME                                            READY   STATUS    RESTARTS   AGE    IP             NODE       NOMINATED NODE   READINESS GATES
pod/virt-launcher-rhel9-custom01-upload-l9hms   1/1     Running   0          3d4h   10.130.2.159   worker02   <none>           1/1

NAME                                                       AGE    PHASE     IP             NODENAME   READY   LIVE-MIGRATABLE   PAUSED
virtualmachineinstance.kubevirt.io/rhel9-custom01-upload   3d4h   Running   10.130.2.159   worker02   True    True

NAME                                               AGE   STATUS    READY
virtualmachine.kubevirt.io/rhel9-custom01-upload   17d   Running   True

なお、現在の CPU / Memory 設定は、画面表示の他に VirtualMachineInstance を参照する事もできます。

$ oc -o json get vmi rhel9-custom01-upload | jq -r '.status | .currentCPUTopology, .memory'
{
  "cores": 1,
  "sockets": 1,
  "threads": 1
}
{
  "guestAtBoot": "2Gi",
  "guestCurrent": "2Gi",
  "guestRequested": "2Gi"
}

Configuration Tab から Memory 2 GiB3 GiB に変更してみます。

image.png

Save ボタンを押すと Live Migration が実行され、即時に VM が更新されます。VM は worker01Live Migration された事が分かります。

image.png

CLI で確認すると、編集前の VM Pod が Completed Status で残存していることが分かります。

$ oc get pod,vmi,vm -o wide
NAME                                            READY   STATUS      RESTARTS   AGE     IP             NODE       NOMINATED NODE   READINESS GATES
pod/virt-launcher-rhel9-custom01-upload-5xm9z   1/1     Running     0          3m54s   10.129.2.118   worker01   <none>           1/1
pod/virt-launcher-rhel9-custom01-upload-l9hms   0/1     Completed   0          3d4h    10.130.2.159   worker02   <none>           1/1

NAME                                                       AGE    PHASE     IP             NODENAME   READY   LIVE-MIGRATABLE   PAUSED
virtualmachineinstance.kubevirt.io/rhel9-custom01-upload   3d4h   Running   10.129.2.118   worker01   True    True

NAME                                                AGE   STATUS    READY
virtualmachine.kubevirt.io/rhel9-custom01-upload    17d   Running   True

Pod Manifest を参照すると Memory Request (.spec.containers[].resources.requests.memory) が変更されたことが分かります。

$ oc -o json get pod | jq -r '.items[] | .metadata.name, .spec.containers[].resources'
virt-launcher-rhel9-custom01-upload-5xm9z
{
  "limits": {
    "devices.kubevirt.io/kvm": "1",
    "devices.kubevirt.io/tun": "1",
    "devices.kubevirt.io/vhost-net": "1"
  },
  "requests": {
    "cpu": "100m",
    "devices.kubevirt.io/kvm": "1",
    "devices.kubevirt.io/tun": "1",
    "devices.kubevirt.io/vhost-net": "1",
    "ephemeral-storage": "50M",
    "memory": "3481272321"
  }
}
virt-launcher-rhel9-custom01-upload-l9hms
{
  "limits": {
    "devices.kubevirt.io/kvm": "1",
    "devices.kubevirt.io/tun": "1",
    "devices.kubevirt.io/vhost-net": "1"
  },
  "requests": {
    "cpu": "100m",
    "devices.kubevirt.io/kvm": "1",
    "devices.kubevirt.io/tun": "1",
    "devices.kubevirt.io/vhost-net": "1",
    "ephemeral-storage": "50M",
    "memory": "2294Mi"
  }
}
Remove Memory

Memory を削除する場合は VM の再起動が必要です。例えば、今回の例で Memory を 3 GiB から 2 GiB に戻す編集を行うと、以下のようなメッセージが表示されます。
image.png

また、Status conditionsRestartRequired が追加されます。
image.png

Live Migration 不可能な VM

以下の VM を編集してみます。この VM は Live Migration 不可能な状態 (Not migratable)worker02 で稼働しています。

image.png

Not migratable にするために、PVC の Access Mode を ReadWriteOnce (RWO) に設定しています。
image.png

$ oc get pod,vmi,vm,pvc -o wide
NAME                                                    READY   STATUS    RESTARTS   AGE   IP            NODE       NOMINATED NODE   READINESS GATES
pod/virt-launcher-rhel9-custom01-not-migratable-jp54z   1/1     Running   0          94s   10.130.3.96   worker02   <none>           1/1

NAME                                                               AGE   PHASE     IP            NODENAME   READY   LIVE-MIGRATABLE   PAUSED
virtualmachineinstance.kubevirt.io/rhel9-custom01-not-migratable   94s   Running   10.130.3.96   worker02   True    False

NAME                                                        AGE   STATUS    READY
virtualmachine.kubevirt.io/rhel9-custom01-not-migratable    95s   Running   True

NAME                           STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS                                 VOLUMEATTRIBUTESCLASS   AGE
rhel9-custom01-not-migratable  Bound    pvc-747519ea-491d-4647-bc2c-b57cdab482ad   30Gi       RWO            ocs-storagecluster-ceph-rbd                  <unset>                 3m44s

Configuration Tab から Memory 2 GiB3 GiB に変更してみます。

image.png

Save ボタンを押すと 画面上では Memory が 3 GiB と表示されますが、Pending changes のメッセージによって VM の更新が一時停止している事が分かります。

image.png

image.png

また、Status conditionsRestartRequired が追加されます。

image.png

image.png

この時点で、Pod は Memory 2 GiB で継続して稼働しています。

$ oc get pod -o wide
NAME                                                READY   STATUS    RESTARTS   AGE   IP            NODE       NOMINATED NODE   READINESS GATES
virt-launcher-rhel9-custom01-not-migratable-jp54z   1/1     Running   0          13m   10.130.3.96   worker02   <none>           1/1

$ oc -o json get pod | jq -r '.items[] | .metadata.name, .spec.containers[].resources'
virt-launcher-rhel9-custom01-not-migratable-jp54z
{
  "limits": {
    "devices.kubevirt.io/kvm": "1",
    "devices.kubevirt.io/tun": "1",
    "devices.kubevirt.io/vhost-net": "1"
  },
  "requests": {
    "cpu": "100m",
    "devices.kubevirt.io/kvm": "1",
    "devices.kubevirt.io/tun": "1",
    "devices.kubevirt.io/vhost-net": "1",
    "ephemeral-storage": "50M",
    "memory": "2294Mi"
  }
}

VM を再起動する事で、更新を反映させます。

image.png

image.png

新しい Pod が起動され、Memory が 3 GiB に変更されている事が分かります。

$ oc get pod -o wide
NAME                                                READY   STATUS    RESTARTS   AGE     IP            NODE       NOMINATED NODE   READINESS GATES
virt-launcher-rhel9-custom01-not-migratable-kqrq8   1/1     Running   0          2m54s   10.130.3.99   worker02   <none>           1/1

$ oc -o json get pod | jq -r '.items[] | .metadata.name, .spec.containers[].resources'
virt-launcher-rhel9-custom01-not-migratable-kqrq8
{
  "limits": {
    "devices.kubevirt.io/kvm": "1",
    "devices.kubevirt.io/tun": "1",
    "devices.kubevirt.io/vhost-net": "1"
  },
  "requests": {
    "cpu": "100m",
    "devices.kubevirt.io/kvm": "1",
    "devices.kubevirt.io/tun": "1",
    "devices.kubevirt.io/vhost-net": "1",
    "ephemeral-storage": "50M",
    "memory": "3481272321"
  }
}

$ oc -o json get vmi rhel9-custom01-not-migratable | jq -r '.status | .currentCPUTopology, .memory'
{
  "cores": 1,
  "sockets": 1,
  "threads": 1
}
{
  "guestAtBoot": "3Gi",
  "guestCurrent": "3Gi",
  "guestRequested": "3Gi"
}
CLI

VirtualMachine Manifest を編集する事で、OCP Console 同等の操作を行う事が出来ます。

Editing a virtual machine by using the command line

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?