Skip to content

Commit

Permalink
lab 7 expand disks
Browse files Browse the repository at this point in the history
  • Loading branch information
christofluethi committed Sep 5, 2024
1 parent 42b7813 commit f139c62
Show file tree
Hide file tree
Showing 4 changed files with 299 additions and 19 deletions.
62 changes: 62 additions & 0 deletions content/en/docs/01/11_kubevirt-configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
title: "1.1 KubeVirt Configuration"
weight: 110
labfoldernumber: "01"
sectionnumber: 1.1
description: >
Kubevirt Configuration
---


## KubeVirt Installation

On the kubernetes cluster used for this training the following operators have been installed.

| Operator Name | Namespace |
|----------------------------------|------------|
| KubeVirt | kubevirt |
| Containerized Data Impoter (CDI) | cdi |

As the configuration and the required feature flags are subject to change we are referencing them on every section.


### Emulation

This cluster is using emulation.
```yaml
apiVersion: kubevirt.io/v1
kind: KubeVirt
metadata:
name: kubevirt
namespace: kubevirt
spec:
configuration:
developerConfiguration:
useEmulation: true
[...]
```


### Enabled FeatureFlags

In the cluster the following kubevirt feature flags are enabled.

```yaml
apiVersion: kubevirt.io/v1
kind: KubeVirt
metadata:
name: kubevirt
namespace: kubevirt
spec:
configuration:
developerConfiguration:
featureGates:
- Sidecar
- CommonInstancetypesDeploymentGate
- ExperimentalIgnitionSupport
- HotplugVolumes
- ExpandDisks
- Snapshot
- VMExport
```
6 changes: 3 additions & 3 deletions content/en/docs/07/72_storageprofiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ Events: <none>

## Create a DataVolume

Lets have a look how this works. Assume we create a DataVolume `my-dv` with the following specification and apply it to the cluster:
Let's have a look how this works. Assume we create a DataVolume `my-dv` with the following specification and apply it to the cluster:
```yaml
apiVersion: cdi.kubevirt.io/v1beta1
kind: DataVolume
metadata:
name: lab07-fs-disk
name: my-dv
spec:
source:
blank: {}
Expand Down Expand Up @@ -138,7 +138,7 @@ When we have the storage profile configured and in place, we can re-apply our Da
apiVersion: cdi.kubevirt.io/v1beta1
kind: DataVolume
metadata:
name: lab07-fs-disk
name: my-dv
spec:
source:
blank: {}
Expand Down
28 changes: 14 additions & 14 deletions content/en/docs/07/74_hotplug-disks.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ Actually we can see that we have two disks available.

## {{% task %}} Create a DataVolume to be hot plugged

Create a file `dv_{{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-hotplug.yaml` with the following content:
Create a file `dv_{{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-hotplug-disk.yaml` with the following content:
```yaml
apiVersion: cdi.kubevirt.io/v1beta1
kind: DataVolume
metadata:
name: {{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-hotplug
name: {{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-hotplug-disk
spec:
source:
blank: {}
Expand All @@ -152,7 +152,7 @@ spec:
Create the data volume with:
```shell
kubectl create -f dv_{{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-hotplug.yaml
kubectl create -f dv_{{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-hotplug-disk.yaml
```


Expand All @@ -161,10 +161,10 @@ kubectl create -f dv_{{% param "labsubfolderprefix" %}}{{% param "labfoldernumbe
Hotplug the disk by using `virtctl`:

```shell
virtctl addvolume {{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-cirros --volume-name={{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-hotplug
virtctl addvolume {{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-cirros --volume-name={{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-hotplug-disk
```
```
Successfully submitted add volume request to VM {{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-cirros for volume {{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-hotplug
Successfully submitted add volume request to VM {{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-cirros for volume {{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-hotplug-disk
```

After some time the device will be hot plugged to your virtual machine. You may get a first hint where your new disk is
Expand Down Expand Up @@ -263,10 +263,10 @@ sudo touch /mnt/disk/myfile

You can remove a hot plugged disk with:
```shell
virtctl removevolume lab07-cirros --volume-name=lab07-hotplug
virtctl removevolume {{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-cirros --volume-name={{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-hotplug-disk
```
```
Successfully submitted remove volume request to VM lab07-cirros for volume lab07-hotplug
Successfully submitted remove volume request to VM {{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-cirros for volume {{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-hotplug-disk
```

What happens if you remount the disk again? Is the created file `/mnt/disk/myfile` still present?
Expand All @@ -289,10 +289,10 @@ With the above steps we have hot plugged a disk into the vm. This mount is not p
or shutdown the disk is not attached. When you want to mount the disk persistently you can use the `--persist` flag.

```shell
virtctl addvolume {{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-cirros --volume-name={{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-hotplug --persist
virtctl addvolume {{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-cirros --volume-name={{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-hotplug-disk --persist
```
```
Successfully submitted add volume request to VM {{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-cirros for volume {{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-hotplug
Successfully submitted add volume request to VM {{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-cirros for volume {{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-hotplug-disk
```

This will add the relevant sections to your `VirtualMachine` manifest. You can show the modified configuration with:
Expand All @@ -304,7 +304,7 @@ kubectl get vm {{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
name: lab07-cirros
name: {{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-cirros
spec:
[...]
template:
Expand All @@ -319,10 +319,10 @@ spec:
- name: cloudinitdisk
disk:
bus: virtio
- name: lab07-hotplug
- name: {{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-hotplug-disk
disk:
bus: scsi
serial: lab07-hotplug
serial: {{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-hotplug-disk
volumes:
- name: containerdisk
containerDisk:
Expand All @@ -331,10 +331,10 @@ spec:
cloudInitNoCloud:
userData: |
#cloud-config
- name: lab07-hotplug
- name: {{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-hotplug-disk
dataVolume:
hotpluggable: true
name: lab07-hotplug
name: {{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-hotplug-disk
[...]
```

Expand Down
Loading

0 comments on commit f139c62

Please sign in to comment.