Skip to content

Commit 3bd3f35

Browse files
authored
Merge pull request #84294 from jherrman/CNV-38575
OSDOCS#38575: Added inferFromVolume to creating VMs from container disks
2 parents cb53b5e + 1826214 commit 3bd3f35

File tree

1 file changed

+21
-74
lines changed

1 file changed

+21
-74
lines changed

modules/virt-creating-vm-import-cli.adoc

Lines changed: 21 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -32,42 +32,7 @@ When the virtual machine (VM) is created, the data volume with the {object} is i
3232
3333
.Procedure
3434

35-
. If the {data-source} requires authentication, create a `Secret` manifest, specifying the credentials, and save it as a `data-source-secret.yaml` file:
36-
+
37-
[source,yaml]
38-
----
39-
apiVersion: v1
40-
kind: Secret
41-
metadata:
42-
name: data-source-secret
43-
labels:
44-
app: containerized-data-importer
45-
type: Opaque
46-
data:
47-
accessKeyId: "" <1>
48-
secretKey: "" <2>
49-
----
50-
<1> Specify the Base64-encoded key ID or user name.
51-
<2> Specify the Base64-encoded secret key or password.
52-
53-
. Apply the `Secret` manifest by running the following command:
54-
+
55-
[source,terminal]
56-
----
57-
$ oc apply -f data-source-secret.yaml
58-
----
59-
60-
. If the VM must communicate with servers that use self-signed certificates or certificates that are not signed by the system CA bundle, create a config map in the same namespace as the VM:
61-
+
62-
[source,terminal]
63-
----
64-
$ oc create configmap tls-certs <1>
65-
--from-file=</path/to/file/ca.pem> <2>
66-
----
67-
<1> Specify the config map name.
68-
<2> Specify the path to the CA certificate.
69-
70-
. Edit the `VirtualMachine` manifest and save it as a `vm-fedora-datavolume.yaml` file:
35+
. Edit the `VirtualMachine` manifest and save it as a `vm-rhel-datavolume.yaml` file:
7136
+
7237
[%collapsible]
7338
====
@@ -77,73 +42,55 @@ apiVersion: kubevirt.io/v1
7742
kind: VirtualMachine
7843
metadata:
7944
creationTimestamp: null
45+
name: vm-rhel-datavolume <1>
8046
labels:
81-
kubevirt.io/vm: vm-fedora-datavolume
82-
name: vm-fedora-datavolume <1>
47+
kubevirt.io/vm: vm-rhel-datavolume
8348
spec:
8449
dataVolumeTemplates:
8550
- metadata:
8651
creationTimestamp: null
87-
name: fedora-dv <2>
52+
name: rhel-dv <2>
8853
spec:
54+
sourceRef:
55+
kind: DataSource
56+
name: rhel9
57+
namespace: openshift-virtualization-os-images
8958
storage:
9059
resources:
9160
requests:
9261
storage: 10Gi <3>
93-
storageClassName: <storage_class> <4>
94-
source:
95-
ifdef::url[]
96-
http:
97-
url: "https://mirror.arizona.edu/fedora/linux/releases/35/Cloud/x86_64/images/Fedora-Cloud-Base-35-1.2.x86_64.qcow2" <5>
98-
endif::[]
99-
ifdef::container-disks[]
100-
registry:
101-
url: "docker://kubevirt/fedora-cloud-container-disk-demo:latest" <5>
102-
endif::[]
103-
secretRef: data-source-secret <6>
104-
certConfigMap: tls-certs <7>
105-
status: {}
106-
running: true
62+
instancetype:
63+
name: u1.small <4>
64+
preference:
65+
inferFromVolume: datavolumedisk1
66+
runStrategy: Always
10767
template:
10868
metadata:
10969
creationTimestamp: null
11070
labels:
111-
kubevirt.io/vm: vm-fedora-datavolume
71+
kubevirt.io/vm: vm-rhel-datavolume
11272
spec:
11373
domain:
114-
devices:
115-
disks:
116-
- disk:
117-
bus: virtio
118-
name: datavolumedisk1
119-
machine:
120-
type: ""
121-
resources:
122-
requests:
123-
memory: 1.5Gi
74+
devices: {}
75+
resources: {}
12476
terminationGracePeriodSeconds: 180
12577
volumes:
12678
- dataVolume:
127-
name: fedora-dv
79+
name: rhel-dv
12880
name: datavolumedisk1
12981
status: {}
13082
----
13183
<1> Specify the name of the VM.
13284
<2> Specify the name of the data volume.
13385
<3> Specify the size of the storage requested for the data volume.
134-
<4> Optional: If you do not specify a storage class, the default storage class is used.
135-
ifdef::url,container-disks[]
136-
<5> Specify the URL of the {data-source}.
137-
endif::[]
138-
<6> Optional: Specify the secret name if you created a secret for the {data-source} access credentials.
139-
<7> Optional: Specify a CA certificate config map.
86+
<4> Optional: Specify the instance type to use to control resource sizing of the VM.
14087
====
14188

14289
. Create the VM by running the following command:
14390
+
14491
[source,terminal]
14592
----
146-
$ oc create -f vm-fedora-datavolume.yaml
93+
$ oc create -f vm-rhel-datavolume.yaml
14794
----
14895
+
14996
The `oc create` command creates the data volume and the VM. The CDI controller creates an underlying PVC with the correct annotation and the import process begins. When the import is complete, the data volume status changes to `Succeeded`. You can start the VM.
@@ -163,15 +110,15 @@ $ oc get pods
163110
+
164111
[source,terminal]
165112
----
166-
$ oc describe dv fedora-dv <1>
113+
$ oc describe dv rhel-dv <1>
167114
----
168115
<1> Specify the data volume name that you defined in the `VirtualMachine` manifest.
169116

170117
. Verify that provisioning is complete and that the VM has started by accessing its serial console:
171118
+
172119
[source,terminal]
173120
----
174-
$ virtctl console vm-fedora-datavolume
121+
$ virtctl console vm-rhel-datavolume
175122
----
176123

177124
ifeval::["{context}" == "creating-vms-from-web-images"]

0 commit comments

Comments
 (0)