OpenShift Virtualization
Red Hat® OpenShift® Virtualization は Red Hat OpenShift に含まれる機能であり、組織が新規および既存の仮想マシン (VM) ワークロードを実行およびデプロイするための先進的なプラットフォームを提供します。このソリューションにより、従来の仮想マシンを、信頼できる、一貫した包括的なハイブリッドクラウド・アプリケーション・プラットフォームに簡単に移行できます。
OpenShift Virtualization は、VM の移行を単純化するとともに、クラウドネイティブ・アプリケーション・プラットフォームのシンプルさと速度を利用してインフラストラクチャのモダナイゼーションの道筋を提供します。また、先進的な管理の原則を取り入れつつ既存の仮想化への投資を維持することを目指しており、Red Hat の包括的な仮想化ソリューションの基盤となります。
Creating VMs from custom images
OCP 4.17 Bare Metal 環境 OpenShift Virtualization (OCP-V) で Virtual Machine (VM) を作成してみます。ここでは以下の手順を参考に、独自に作成した Custom Image
から作成してみます。
Creating VMs from custom images
Custom Image
では以下の4つの方法がありますが、今回は2番目の方法で行ってみます。
- Importing the image as a container disk from a registry.
Optional: You can enable auto updates for your container disks. See Managing automatic boot source updates for details.- Importing the image from a web page.
- Uploading the image from a local machine.
- Cloning a persistent volume claim (PVC) that contains the image.
なお、それぞれの方法によってサポートされるフォーマットが指定されています。
CDI supported operations matrix
また、処理の過程で Scratch Space (一時ストレージ領域)
を使用します。
Preparing CDI scratch space
Importing the image from a web page
今回は、Red Hat 公式サイトの Red Hat Enterprise Linux 9.5 KVM Guest Image (QCOW2 -QEMU Copy On Write version 2- Format File)
を使用してみます。指定する URL は、予め以下の Download Now
ボタンから確認しておきます。
Download Red Hat Enterprise Linux
OCP Console から Virtualization -> Catalog を表示します。画面が Template catalog
Tab になっている事を確認します。
左上の Project に VM を作成する Project として z-ocpv-vmtest-custom
を指定した上で、Red Hat Enterprise Linux 9 VM
Template を選択します。Disk source
から URL (creates PVC)
を選択し、Image URL
に先程確認した URL を指定します。
その他の必要な箇所の設定変更を行います。今回は VirtualMachine name
のみ rhel9-custom01-webpage
に変更しています。
Quick create VirtualMachine
ボタンを押して VM を作成します。以下のような画面が表示され、Status Running
になれば完了です。
なお、今回の手順では、以下のような DataVolume
が作成され、.spec.source.http.url
に指定した URL が登録されます。
$ oc get datavolume
NAME PHASE PROGRESS RESTARTS AGE
rhel9-custom01-webpage Succeeded 100.0% 45m
$ oc -o yaml get datavolume rhel9-custom01-webpage
apiVersion: cdi.kubevirt.io/v1beta1
kind: DataVolume
metadata:
annotations:
cdi.kubevirt.io/allowClaimAdoption: "true"
cdi.kubevirt.io/storage.usePopulator: "true"
labels:
kubevirt.io/created-by: 878c67a3
name: rhel9-custom01-webpage
namespace: z-ocpv-vmtest-custom
ownerReferences:
- apiVersion: kubevirt.io/v1
blockOwnerDeletion: true
controller: true
kind: VirtualMachine
name: rhel9-custom01-webpage
spec:
source:
http:
url: https://access.cdn.redhat.com/content/origin/files/sha256/9d/9d11248599b91178a600202412ad3ffc6f1c75c050d7b3c5484dc3f46fc06582/rhel-9.5-x86_64-kvm.qcow2?user=xxxxxxxxx&_auth_=zzzzzzzzzzzz
storage:
resources:
requests:
storage: 30Gi
~省略~
今回使用した URL には Red Hat 公式サイトのログイン情報が含まれていますが、別途 Secret
として登録する事も可能です。
$ oc explain datavolume.spec.source.http
GROUP: cdi.kubevirt.io
KIND: DataVolume
VERSION: v1beta1
FIELD: http <Object>
DESCRIPTION:
DataVolumeSourceHTTP can be either an http or https endpoint, with an
optional basic auth user name and password, and an optional configmap
containing additional CAs
FIELDS:
certConfigMap <string>
CertConfigMap is a configmap reference, containing a Certificate
Authority(CA) public key, and a base64 encoded pem certificate
extraHeaders <[]string>
ExtraHeaders is a list of strings containing extra headers to include with
HTTP transfer requests
secretExtraHeaders <[]string>
SecretExtraHeaders is a list of Secret references, each containing an extra
HTTP header that may include sensitive information
secretRef <string>
SecretRef A Secret reference, the secret should contain accessKeyId (user
name) base64 encoded, and secretKey (password) also base64 encoded
url <string> -required-
URL is the URL of the http(s) endpoint
v1beta1.DataVolumeSourceHTTP