diff --git a/CNV/README.md b/CNV/README.md index d673e37..d30cbcd 100644 --- a/CNV/README.md +++ b/CNV/README.md @@ -1,10 +1,57 @@ # Container Native Virtualization Deployment -## What does it do +## Access to Developer & QE Content +To get access to downstream bundles, you need to be granted permission in quay. +If you see "Application not found" from this [quay application registry](https://quay.io/application/rh-osbs-operators/kubevirt-hyperconverged), +then fill out [this form](https://docs.google.com/spreadsheets/d/1OyUtbu9aiAi3rfkappz5gcq5FjUbMQtJG4jZCNqVT20/edit#gid=0) to get access. -The script [deploy-cnv.sh](deploy-cnv.sh) deploys *CNV 2.0* through [OLM](https://github.com/operator-framework/operator-lifecycle-manager), meaning: +## CNV 2.1 for HTB +`cnv-2.1.0.sh` is a clone of `https://pkgs.devel.redhat.com/cgit/containers/hco-bundle-registry/tree/marketplace-qe-testing.sh?h=cnv-2.1-rhel-8`. -* Creates a resource *Subscription* which triggers the deployment of all the operators that are required for CNV to work -* Waits for the operator pods to be ready -* Creates the custom resource *HyperConverged*, which makes the operators to deploy all their components and register the provided resources for them to be available (apiservices, CRDs, ...) -* Finally, waits for the new pods to be ready and CNV is ready to be used +Variables: +```bash +# The Namespace and Version of CNV +TARGET_NAMESPACE="${TARGET_NAMESPACE:-openshift-cnv}" +CNV_VERSION="${CNV_VERSION:-2.1.0}" + +RETRIES="${RETRIES:-10}" + +# Registry Auth +QUAY_USERNAME +QUAY_PASSWORD +``` + +## Upgrade +`cnv-upgrade.sh` is a clone of `curl -k https://pkgs.devel.redhat.com/cgit/containers/hco-bundle-registry/plain/qe-upgrade.sh?h=cnv-2.1-rhel-8`. + +Variables: +```bash +OLD_CNV_VERSION="${CNV_VERSION:-2.1.0}" +CNV_VERSION="${CNV_VERSION:-2.1.0}" + +# The Namespace and Version of CNV +TARGET_NAMESPACE="${TARGET_NAMESPACE:-openshift-cnv}" +``` +The expectation is that the $CNV_VERSION CSV file `replaces` the $OLD_CNV_VERSION's +CSV file. + +## Debugging +```bash +# CNV pod status +oc get pods -n openshift-cnv +oc get hco -n openshift-cnv hyperconverged-cluster -o=jsonpath='{range .status.conditions[*]}{.type}{"\t"}{.status}{"\t"}{.message}{"\n"}{end}' + +# Marketplace Resources +oc get operatorsource -n openshift-marketplace +oc get catalogsourceconfig -n openshift-marketplace +oc get packagemanifest -n openshift-cnv +oc get pods -n openshift-marketplace + +# OLM Resources +oc get sub -n openshift-cnv -o yaml +oc get catalogsource --all-namespaces +oc get installplan -n openshift-cnv + +# Cluster +oc get clusterversion +``` diff --git a/CNV/cnv-2.1.0.sh b/CNV/cnv-2.1.0.sh new file mode 100755 index 0000000..bf42c23 --- /dev/null +++ b/CNV/cnv-2.1.0.sh @@ -0,0 +1,156 @@ +#!/bin/bash + +set -ex + +globalNamespace=`oc -n openshift-operator-lifecycle-manager get deployments catalog-operator -o jsonpath='{.spec.template.spec.containers[].args[1]}'` +echo "Global Namespace: ${globalNamespace}" + +APP_REGISTRY="${APP_REGISTRY:-rh-osbs-operators}" +PACKAGE="${PACKAGE:-kubevirt-hyperconverged}" +CSC_SOURCE="${CSC_SOURCE:-hco-catalogsource-config}" +TARGET_NAMESPACE="${TARGET_NAMESPACE:-openshift-cnv}" +CLUSTER="${CLUSTER:-OPENSHIFT}" +MARKETPLACE_NAMESPACE="${MARKETPLACE_NAMESPACE:-openshift-marketplace}" +GLOBAL_NAMESPACE="${GLOBAL_NAMESPACE:-$globalNamespace}" +CNV_VERSION="${CNV_VERSION:-2.1.0}" + +RETRIES="${RETRIES:-10}" + +oc create ns $TARGET_NAMESPACE || true + +QUAY_USERNAME="${QUAY_USERNAME:-}" +QUAY_PASSWORD="${QUAY_PASSWORD:-}" + +if [ "${CLUSTER}" == "KUBERNETES" ]; then + MARKETPLACE_NAMESPACE="marketplace" +fi + +if [ -z "${QUAY_USERNAME}" ]; then + echo "QUAY_USERNAME" + read QUAY_USERNAME +fi + +if [ -z "${QUAY_PASSWORD}" ]; then + echo "QUAY_PASSWORD" + read -s QUAY_PASSWORD +fi + +TOKEN=$(curl -sH "Content-Type: application/json" -XPOST https://quay.io/cnr/api/v1/users/login -d ' +{ + "user": { + "username": "'"${QUAY_USERNAME}"'", + "password": "'"${QUAY_PASSWORD}"'" + } +}' | jq -r '.token') + +echo $TOKEN +if [ "${TOKEN}" == "null" ]; then + echo "TOKEN was 'null'. Did you enter the correct quay Username & Password?" + exit 1 +fi + +echo "Creating registry secret" +cat < /dev/null)" ]; do - sleep 10 -done - -oc wait --for condition=ready pod -l name=hyperconverged-cluster-operator -n ${OPERATORS_NAMESPACE} --timeout=2400s -oc wait --for condition=ready pod -l kubevirt.io=virt-operator -n ${OPERATORS_NAMESPACE} --timeout=2400s -oc wait --for condition=ready pod -l name=cdi-operator -n ${OPERATORS_NAMESPACE} --timeout=2400s -oc wait --for condition=ready pod -l name=kubevirt-web-ui-operator -n ${OPERATORS_NAMESPACE} --timeout=2400s -oc wait --for condition=ready pod -l name=cluster-network-addons-operator -n ${OPERATORS_NAMESPACE} --timeout=2400s -oc wait --for condition=ready pod -l name=kubevirt-ssp-operator -n ${OPERATORS_NAMESPACE} --timeout=2400s -oc wait --for condition=ready pod -l name=node-maintenance-operator -n ${OPERATORS_NAMESPACE} --timeout=2400s - - -echo "Launching CNV..." -cat < /dev/null)" ]; do - sleep 10 -done - -oc wait --for condition=ready pod -l cdi.kubevirt.io -n ${OPERATORS_NAMESPACE} --timeout=2400s - -while [ "x" == "x$(oc get pods -l kubevirt.io=virt-api -n ${OPERATORS_NAMESPACE} 2> /dev/null)" ]; do - sleep 10 -done - -oc wait --for condition=ready pod -l kubevirt.io=virt-api -n ${OPERATORS_NAMESPACE} --timeout=2400s - -while [ "x" == "x$(oc get pods -l kubevirt.io=virt-controller -n ${OPERATORS_NAMESPACE} 2> /dev/null)" ]; do - sleep 10 -done - -oc wait --for condition=ready pod -l kubevirt.io=virt-controller -n ${OPERATORS_NAMESPACE} --timeout=2400s - -while [ "x" == "x$(oc get pods -l kubevirt.io=virt-handler -n ${OPERATORS_NAMESPACE} 2> /dev/null)" ]; do - sleep 10 -done - -oc wait --for condition=ready pod -l kubevirt.io=virt-handler -n ${OPERATORS_NAMESPACE} --timeout=2400s - -while [ "x" == "x$(oc get pods -l kubevirt.io=virt-template-validator -n ${OPERATORS_NAMESPACE} 2> /dev/null)" ]; do - sleep 10 -done - -oc wait --for condition=ready pod -l kubevirt.io=virt-template-validator -n ${OPERATORS_NAMESPACE} --timeout=2400s - -while [ "x" == "x$(oc get pods -l app=bridge-marker -n ${LINUX_BRIDGE_NAMESPACE} 2> /dev/null)" ]; do - sleep 10 -done - -oc wait --for condition=ready pod -l app=bridge-marker -n ${LINUX_BRIDGE_NAMESPACE} --timeout=2400s -oc wait --for condition=ready pod -l app=cni-plugins -n ${LINUX_BRIDGE_NAMESPACE} --timeout=2400s - -while [ "x" == "x$(oc get pods -l app=kubevirt-web-ui -n ${KWEB_UI_NAMESPACE} 2> /dev/null)" ]; do - sleep 10 -done - -oc wait --for condition=ready pod -l app=kubevirt-web-ui -n ${KWEB_UI_NAMESPACE} --timeout=2400s - -while [ "x" == "x$(oc get pods -l app=kubevirt-node-labeller -n ${OPERATORS_NAMESPACE} 2> /dev/null)" ]; do - sleep 10 -done - -oc wait --for condition=ready pod -l app=kubevirt-node-labeller -n ${OPERATORS_NAMESPACE} --timeout=2400s - - -echo "Done installing CNV!"