Virtualization
-
virtctlbinaries on the OCP bastion - OS images
Post Configuration
- Create hyperconverged
- Ensure that it is reconciled successfully.
- Also check the namespace
openshift-virtualization-os-imagesis created without any hanging removals
- StorageClasses
- Ensure that the
scbeing used supports Block storage, RWX and RWO.
- Ensure that the
- Create DV for uploading images:
apiVersion: cdi.kubevirt.io/v1beta1 kind: DataVolume metadata: name: rhcos-iso namespace: openshift-cnv spec: source: upload: {} # <— tells CDI to expect an upload pvc: storageClassName: portworx accessModes: - ReadWriteMany # RWX for iso images that will be reused vms volumeMode: Filesystem #File System for ISO resources: requests: storage: 20Gi - Upload ISO image:
#On OCP Bastion with virtctl binaries: virtctl image-upload dv <dv-name> -n openshift-cnv --image-path=/rhcos-live-iso.x86_64.iso --no-create --insecure
Multus Network
In order to have the VMs be reachable by instances outside of the Pod Network CIDR, NMState needs to be used to attach the VM's NIC to the host.
- Install NMState Operator
- Create NMState
- Create the NodeNetworkConfigurationPolicy.yaml
apiVersion: nmstate.io/v1 kind: NodeNetworkConfigurationPolicy metadata: name: br-ex-nested spec: nodeSelector: node-role.kubernetes.io/worker: "" desiredState: ovn: bridge-mappings: - localnet: br-ex-nested bridge: br-ex state: present - Create the Network Attachment Definition for the VMs to use.
apiVersion: k8s.cni.cncf.io/v1 kind: NetworkAttachmentDefinition metadata: name: br-ex-nested namespace: openshift-cnv spec: config: | { "cniVersion": "0.4.0", "name": "br-ex-nested", "type": "ovn-k8s-cni-overlay", "topology": "localnet", "netAttachDefName": "openshift-cnv/br-ex-nested" }
PVC Creation (Disk Storage)
Create a empty PVC to act as the 'Disks' for the VMs:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: rhcos-01
namespace: openshift-cnv
spec:
storageClassName: portworx
accessModes: ["ReadWriteOnce"]
volumeMode: Block #Block for faster IOPS
resources:
requests:
storage: 200Gi
VM Creation
Create the VM and match the names of the PVC and ISOs used:
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
name: discomaster-01
namespace: openshift-cnv
spec:
running: false
template:
spec:
domain:
devices:
interfaces:
- name: default
masquerade: {}
- bridge: {}
name: br-ex-net
disks:
- name: installiso
cdrom:
bus: sata
- name: rootdisk
disk: { bus: virtio }
resources:
requests:
memory: 32Gi
networks:
- name: default
pod: {}
- multus:
networkName: br-ex-nested
name: br-ex-net
volumes:
- name: installiso
persistentVolumeClaim:
claimName: rhcos-iso # Your uploaded ISO (Filesystem)
- name: rootdisk
persistentVolumeClaim:
claimName: discomaster-01