A unified operator deploying and controlling KubeVirt and several adjacent operators:
- Containerized Data Importer
- Scheduling, Scale and Performance
- Cluster Network Addons
- Node Maintenance
This operator is typically installed from the Operator Lifecycle Manager (OLM), and creates operator CustomResources (CRs) for its underlying operators as can be seen in the diagram below. Use it to obtain an opinionated deployment of KubeVirt and its helper operators.
In the HCO components doc you can get an up-to-date overview of the involved components.
To install the default community HyperConverged Cluster Operator, along with its underlying components, run:
$ curl -L https://api.github.com/repos/kubevirt/hyperconverged-cluster-operator/tarball/main | \
tar --strip-components=1 -xvzf - kubevirt-hyperconverged-cluster-operator-*/deploy/kustomize
$ ./deploy/kustomize/deploy_kustomize.sh
The deployment is completed when HCO custom resource reports its condition as Available
.
For more explanation and advanced options for HCO deployment using kustomize, refer to kustomize deployment documentation.
Hyperconverged Cluster Operator is publishing the latest bundle to quay.io/kubevirt
before publishing tagged, stable releases to OperatorHub.io.
The latest bundle is quay.io/kubevirt/hyperconverged-cluster-bundle:1.14.0-unstable
. It is built and pushed on every merge to
main branch, and contains the most up-to-date manifests, which are pointing to the most recent application images: hyperconverged-cluster-operator
and hyperconverged-cluster-webhook
, which are built together with the bundle from the current code at the main branch.
The unreleased bundle can be consumed on a cluster by creating a CatalogSource pointing to the index image that contains
that bundle: quay.io/kubevirt/hyperconverged-cluster-index:1.14.0-unstable
.
Make the bundle available in the cluster's packagemanifest by adding the following CatalogSource:
cat <<EOF | oc apply -f -
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
name: hco-unstable-catalog-source
namespace: openshift-marketplace
spec:
sourceType: grpc
image: quay.io/kubevirt/hyperconverged-cluster-index:1.14.0-unstable
displayName: Kubevirt Hyperconverged Cluster Operator
publisher: Kubevirt Project
EOF
Then, create a namespace, subscription and an OperatorGroup to deploy HCO via OLM:
cat <<EOF | oc apply -f -
apiVersion: v1
kind: Namespace
metadata:
name: kubevirt-hyperconverged
---
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: kubevirt-hyperconverged-group
namespace: kubevirt-hyperconverged
---
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: hco-operatorhub
namespace: kubevirt-hyperconverged
spec:
source: hco-unstable-catalog-source
sourceNamespace: openshift-marketplace
name: community-kubevirt-hyperconverged
channel: "candidate-v1.14"
EOF
Then, create the HyperConverged custom resource to complete the installation. Further information about the HyperConverged CR and its possible configuration options can be found in the Cluster Configuration doc.
Run the following script to apply the HCO operator:
$ curl https://raw.githubusercontent.com/kubevirt/hyperconverged-cluster-operator/main/deploy/deploy.sh | bash
Developer Workflow (using OLM)
Build the HCO container using the Makefile recipes make container-build
and
make container-push
with vars IMAGE_REGISTRY
, REGISTRY_NAMESPACE
, and IMAGE_TAG
to direct it's location.
To use the HCO's container, we'll use a registry image to serve metadata to OLM. Build and push the HCO's registry image.
# e.g. quay.io, docker.io
export IMAGE_REGISTRY=<image_registry>
export REGISTRY_NAMESPACE=<container_org>
export IMAGE_TAG=example
# build the container images and push them to registry
make container-build container-push
export HCO_OPERATOR_IMAGE=$IMAGE_REGISTRY/$REGISTRY_NAMESPACE/hyperconverged-cluster-operator:$IMAGE_TAG
export HCO_WEBHOOK_IMAGE=$IMAGE_REGISTRY/$REGISTRY_NAMESPACE/hyperconverged-cluster-webhook:$IMAGE_TAG
export ARTIFACTS_SERVER_IMAGE=$IMAGE_REGISTRY/$REGISTRY_NAMESPACE/virt-artifacts-server:$IMAGE_TAG
# Image to be used in CSV manifests
HCO_OPERATOR_IMAGE=$HCO_OPERATOR_IMAGE CSV_VERSION=$CSV_VERSION make build-manifests
sed -i "s|+WEBHOOK_IMAGE_TO_REPLACE+|${HCO_WEBHOOK_IMAGE}|g" deploy/index-image/community-kubevirt-hyperconverged/1.12.0/manifests/kubevirt-hyperconverged-operator.v1.12.0.clusterserviceversion.yaml
sed -i "s|+ARTIFACTS_SERVER_IMAGE_TO_REPLACE+|${ARTIFACTS_SERVER_IMAGE}|g" deploy/index-image/community-kubevirt-hyperconverged/1.12.0/manifests/kubevirt-hyperconverged-operator.v1.12.0.clusterserviceversion.yaml
Create the namespace for the HCO.
$ kubectl create ns kubevirt-hyperconverged
For the next set of commands, we will use the
operator-sdk
CLI tool. Below commands will create a
bundle image, push this image, and finally use that bundle image to install the HyperConverged cluster
Operator on the OLM-enabled cluster.
operator-sdk generate bundle --input-dir deploy/index-image/ --output-dir _out/bundle
operator-sdk bundle validate _out/bundle # optional
podman build -f deploy/index-image/bundle.Dockerfile -t $IMAGE_REGISTRY/$REGISTRY_NAMESPACE/hyperconverged-cluster-index:$IMAGE_TAG
podman push $IMAGE_REGISTRY/$REGISTRY_NAMESPACE/hyperconverged-cluster-index:$IMAGE_TAG
operator-sdk bundle validate $IMAGE_REGISTRY/$REGISTRY_NAMESPACE/hyperconverged-cluster-index:$IMAGE_TAG
operator-sdk run bundle -n kubevirt-hyperconverged $IMAGE_REGISTRY/$REGISTRY_NAMESPACE/hyperconverged-cluster-index:$IMAGE_TAG
Create an HCO CustomResource, which creates the KubeVirt CR, launching KubeVirt, CDI (Containerized Data Importer), Network-addons, VM import, TTO (Tekton Tasks Operator) and SSP (Scheduling, Scale and Performance) Operator.
$ kubectl create -f deploy/hco.cr.yaml -n kubevirt-hyperconverged
- Choose the provider
#For k8s cluster:
$ export KUBEVIRT_PROVIDER="k8s-1.17"
#For okd cluster:
$ export KUBEVIRT_PROVIDER="okd-4.1"
- Navigate to the project's directory
$ cd <path>/hyperconverged-cluster-operator
- Remove an old cluster
$ make cluster-down
- Create a new cluster
$ make cluster-up
- Clean previous HCO deployment and re-deploy HCO
(When making a change, execute only this command - no need to repeat steps 1-3)
$ make cluster-sync
Use ./cluster/kubectl.sh
as the command-line tool.
For example:
$ ./cluster/kubectl.sh get pods --all-namespaces
In order to use HCO on top of external provider, i.e CRC, use:
export KUBEVIRT_PROVIDER=external
export IMAGE_REGISTRY=<container image repository, such as quay.io, default: quay.io>
export REGISTRY_NAMESPACE=<your org under IMAGE_REGISTRY, i.e your_name if you use quay.io/your_name, default: kubevirt>
make cluster-sync
oc
binary should exist, and the cluster should be reachable via oc
commands.