Installing OKD Virtualization using the CLI

Install OKD Virtualization to add virtualization functionality to your OKD cluster. You can subscribe to and deploy the OKD Virtualization Operators by using the command line to apply manifests to your cluster.

To specify the nodes where you want OKD Virtualization to install its components, configure node placement rules.

Prerequisites

  • Install OKD 4.9 on your cluster.

  • Install the OpenShift CLI (oc).

  • Log in as a user with cluster-admin privileges.

Subscribing to the OKD Virtualization catalog by using the CLI

Before you install OKD Virtualization, you must subscribe to the OKD Virtualization catalog. Subscribing gives the openshift-cnv namespace access to the OKD Virtualization Operators.

To subscribe, configure Namespace, OperatorGroup, and Subscription objects by applying a single manifest to your cluster.

Procedure

  1. Create a YAML file that contains the following manifest:

    1. apiVersion: v1
    2. kind: Namespace
    3. metadata:
    4. name: openshift-cnv
    5. ---
    6. apiVersion: operators.coreos.com/v1
    7. kind: OperatorGroup
    8. metadata:
    9. name: kubevirt-hyperconverged-group
    10. namespace: openshift-cnv
    11. spec:
    12. targetNamespaces:
    13. - openshift-cnv
    14. ---
    15. apiVersion: operators.coreos.com/v1alpha1
    16. kind: Subscription
    17. metadata:
    18. name: hco-operatorhub
    19. namespace: openshift-cnv
    20. spec:
    21. source: redhat-operators
    22. sourceNamespace: openshift-marketplace
    23. name: kubevirt-hyperconverged
    24. startingCSV: kubevirt-hyperconverged-operator.v4.9.1
    25. channel: "stable" (1)
    1Using the stable channel ensures that you install the version of OKD Virtualization that is compatible with your OKD version.
  2. Create the required Namespace, OperatorGroup, and Subscription objects for OKD Virtualization by running the following command:

    1. $ oc apply -f <file name>.yaml

You can configure certificate rotation parameters in the YAML file.

Deploying the OKD Virtualization Operator by using the CLI

You can deploy the OKD Virtualization Operator by using the oc CLI.

Prerequisites

  • An active subscription to the OKD Virtualization catalog in the openshift-cnv namespace.

Procedure

  1. Create a YAML file that contains the following manifest:

    1. apiVersion: hco.kubevirt.io/v1beta1
    2. kind: HyperConverged
    3. metadata:
    4. name: kubevirt-hyperconverged
    5. namespace: openshift-cnv
    6. spec:
  2. Deploy the OKD Virtualization Operator by running the following command:

    1. $ oc apply -f <file_name>.yaml

Verification

  • Ensure that OKD Virtualization deployed successfully by watching the PHASE of the cluster service version (CSV) in the openshift-cnv namespace. Run the following command:

    1. $ watch oc get csv -n openshift-cnv

    The following output displays if deployment was successful:

    Example output

    1. NAME DISPLAY VERSION REPLACES PHASE
    2. kubevirt-hyperconverged-operator.v4.9.1 OKD Virtualization 4.9.1 Succeeded

Next steps

You might want to additionally configure the following components:

  • The hostpath provisioner is a local storage provisioner designed for OKD Virtualization. If you want to configure local storage for virtual machines, you must enable the hostpath provisioner first.