This is a cache of https://docs.openshift.com/container-platform/4.5/virt/install/installing-virt-cli.html. It is a snapshot of the page at 2024-11-23T00:54:26.023+0000.
Installing OpenShift Virtualization using the <strong>cli</strong> - OpenShift Virtualization installation | OpenShift Virtualization | OpenShift Container Platform 4.5
×

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

Prerequisites

  • Install OpenShift Container Platform 4.5 on your cluster.

  • Install the OpenShift cli (oc).

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

Subscribing to the OpenShift Virtualization catalog by using the cli

Before you install OpenShift Virtualization, you must subscribe to the OpenShift Virtualization catalog. Subscribing gives the openshift-cnv namespace access to the OpenShift 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:

    apiVersion: v1
    kind: Namespace
    metadata:
      name: openshift-cnv
    ---
    apiVersion: operators.coreos.com/v1
    kind: OperatorGroup
    metadata:
      name: kubevirt-hyperconverged-group
      namespace: openshift-cnv
    spec:
      targetNamespaces:
        - openshift-cnv
    ---
    apiVersion: operators.coreos.com/v1alpha1
    kind: Subscription
    metadata:
      name: hco-operatorhub
      namespace: openshift-cnv
    spec:
      source: redhat-operators
      sourceNamespace: openshift-marketplace
      name: kubevirt-hyperconverged
      startingCSV: kubevirt-hyperconverged-operator.v2.4.9
      channel: "2.4"
  2. Create the required Namespace, OperatorGroup, and Subscription objects for OpenShift Virtualization by running the following command:

    $ oc apply -f <file name>.yaml

Deploying the OpenShift Virtualization Operator by using the cli

You can deploy the OpenShift Virtualization Operator by using the oc cli.

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

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

    apiVersion: hco.kubevirt.io/v1alpha1
    kind: HyperConverged
    metadata:
      name: kubevirt-hyperconverged
      namespace: openshift-cnv
    spec:
      BareMetalPlatform: true
  2. Deploy the OpenShift Virtualization Operator by running the following command:

    $ oc apply -f <file name>.yaml
Verification
  • Ensure that OpenShift Virtualization deployed successfully by watching the PHASE of the ClusterServiceVersion (CSV) in the openshift-cnv namespace. Run the following command:

    $ watch oc get csv -n openshift-cnv

    The following output displays if deployment was successful:

    Example output
    NAME                                      DISPLAY                    VERSION   REPLACES   PHASE
    kubevirt-hyperconverged-operator.v2.4.9   OpenShift Virtualization   2.4.9                Succeeded

Next steps

You might want to additionally configure the following components:

  • The KubeMacPool component provides a MAC address pool service for virtual machine NICs in designated namespaces. Enable a MAC address pool in a namespace by applying the KubeMacPool label to that namespace.

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