Openshift OCPV¶
OpenShift Virtualization (OCPV) Content Bundle¶
This content bundle provides automation for deploying and managing OpenShift Virtualization (formerly known as Container-Native Virtualization) on OpenShift clusters. OpenShift Virtualization enables you to run and manage virtual machine workloads alongside container workloads on the same OpenShift platform.
Overview¶
OpenShift Virtualization allows organizations to:
- Migrate Traditional Workloads: Move VM-based applications to containers
- Unified Platform: Manage containers and VMs from a single control plane
- Streamlined Operations: Use Kubernetes-native tools for VM lifecycle management
- Consistent Security Model: Apply the same security controls to VMs and containers
- Simplified Disaster Recovery: Leverage Kubernetes-native backup and DR solutions for VMs
This content bundle automates the installation, configuration, and management of OpenShift Virtualization capabilities on your cluster.
Prerequisites¶
Before deploying OpenShift Virtualization, ensure you have:
- A fully operational OpenShift cluster (4.12+)
- Sufficient cluster resources:
- At least 3 worker nodes
- Minimum 16GB RAM per worker node
- Minimum 4 vCPUs per worker node
- Sufficient storage for VM disks (see Storage Considerations)
- Virtualization support enabled at the hardware level
- Cluster administrator privileges
Installation Methods¶
There are two ways to install OpenShift Virtualization with this content bundle:
Method 1: During OpenShift Deployment¶
Apply the openshift-config-ocpv profile before deploying your OpenShift cluster:
# Apply the OpenShift Virtualization profile to your cluster configuration
drpcli clusters addprofile demo openshift-config-ocpv
# The installation will proceed automatically after cluster deployment
With this profile applied, the OpenShift deployment process will automatically install OpenShift Virtualization after the cluster is operational.
Method 2: Post-Deployment Installation¶
If your OpenShift cluster is already deployed, you can install OpenShift Virtualization using the provided blueprint:
# Get your cluster UUID (replace "demo" with your cluster name)
CLUSTER_UUID=$(drpcli clusters show Name:demo | jq -r .Uuid)
# Create a work order to run the OCPV installation blueprint
drpcli clusters work_order add $CLUSTER_UUID openshift-cluster-ocpv-install
Installation Process¶
The OpenShift Virtualization installation process follows these steps:
- Creating the
openshift-cnvnamespace - Configuring the OperatorGroup for CNV
- Creating the subscription to the OpenShift Virtualization operator
- Waiting for the operator installation to complete
- Deploying the HyperConverged custom resource
- Waiting for the deployment to reach a ready state
The process typically takes 10-15 minutes to complete, depending on your cluster resources and network speed.
Storage Considerations¶
OpenShift Virtualization requires appropriate storage to manage virtual machine disks. The content bundle supports several storage options:
Hostpath Provisioner (HPP)¶
For development and testing environments, you can use the Hostpath Provisioner, which uses node-local storage:
apiVersion: hostpathprovisioner.kubevirt.io/v1beta1
kind: HostPathProvisioner
metadata:
name: hostpath-provisioner
spec:
imagePullPolicy: IfNotPresent
storagePools:
- name: vm-storage-pool
path: "/var/vm-volumes"
workload:
nodeSelector:
kubernetes.io/os: linux
StorageClass Configuration¶
Create an appropriate StorageClass with volumeBindingMode: WaitForFirstConsumer:
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: vm-storage
provisioner: kubevirt.io.hostpath-provisioner
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
parameters:
storagePool: vm-storage-pool
Managing Virtual Machines¶
After installation, you can manage VMs through:
- OpenShift Web Console: Navigate to the Virtualization section
- Command Line: Use the
ocCLI with virtualization resources
Creating VMs via CLI¶
First, create a namespace for your VM workloads:
# Create a namespace for VM workloads
cat <<EOF | oc apply -f -
---
apiVersion: v1
kind: Namespace
metadata:
name: vm-workloads
labels:
name: vm-workloads
EOF
Then create a virtual machine:
# Create a simple VM
cat <<EOF | oc apply -f -
---
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
name: vm-simple
namespace: vm-workloads
spec:
running: true
template:
metadata:
labels:
kubevirt.io/vm: vm-simple
spec:
domain:
devices:
disks:
- disk:
bus: virtio
name: rootdisk
- disk:
bus: virtio
name: cloudinitdisk
interfaces:
- masquerade: {}
name: default
machine:
type: q35
resources:
requests:
memory: 1Gi
cpu: 1
networks:
- name: default
pod: {}
volumes:
- containerDisk:
image: quay.io/containerdisks/fedora:latest
name: rootdisk
- cloudInitNoCloud:
userData: |-
#cloud-config
password: fedora
chpasswd: { expire: False }
ssh_pwauth: True
name: cloudinitdisk
EOF
# Start/Stop VM operations
virtctl start vm-simple -n vm-workloads
virtctl stop vm-simple -n vm-workloads -p '{"spec":{"running":false}}' --type=merge
# Connect to VM console
virtctl console vm-simple -n vm-workloads
Importing VM Disks¶
# Create a DataVolume for VM import
cat <<EOF | oc create -f -
apiVersion: cdi.kubevirt.io/v1beta1
kind: DataVolume
metadata:
name: my-vm-disk
spec:
source:
http:
url: "https://example.com/disk.qcow2"
pvc:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
EOF
Cleanup and Removal¶
If you need to remove OpenShift Virtualization from your cluster, use the provided cleanup blueprint:
# Get your cluster UUID
CLUSTER_UUID=$(drpcli clusters show demo | jq -r .Uuid)
# Create a work order to run the OCPV cleanup blueprint
drpcli clusters work_order on $CLUSTER_UUID openshift-cluster-ocpv-cleanup
The cleanup process removes: 1. HyperConverged resource 2. Operator subscription 3. ClusterServiceVersions 4. OperatorGroup 5. Supporting resources 6. openshift-cnv namespace
Troubleshooting¶
Verifying Installation¶
Check the status of the installation components:
# Check the HyperConverged resource status
oc get hco -n openshift-cnv
# Check operator pods
oc get pods -n openshift-cnv
# View events for troubleshooting
oc get events -n openshift-cnv --sort-by='.lastTimestamp'
Common Issues¶
-
Storage Provisioning Issues: Verify your storage configuration and ensure that PVCs can be created.
-
Resource Constraints: Ensure nodes have sufficient resources for virtualization.
-
Hardware Virtualization Support: Verify nodes have virtualization extensions enabled.
Support¶
For issues or questions: - Check the Digital Rebar documentation - Review the OpenShift Virtualization documentation - Contact RackN support
License¶
RackN License - See documentation for details.