Skip to content

Commit

Permalink
Refactor code of variuos CDI installations:
Browse files Browse the repository at this point in the history
* cluster-sync/install.sh - contains all supported installation techniques
  and a install_cdi method that derives the technique based on CDI_INSTALL variable
	- operator manifests
        - OLM manifests
* per provider there is cluster-sync/${PROVIDER}/install.sh that has the settting for CDI_INSTALL
  for specific provider
* default technique is CDI installation via operator
  • Loading branch information
annastopel committed Jun 24, 2019
1 parent 2c29c95 commit 8009b34
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 57 deletions.
24 changes: 2 additions & 22 deletions cluster-sync/ephemeral_provider.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env bash
set -e

source cluster-sync/install.sh

function seed_images(){
container=""
container_alias=""
Expand Down Expand Up @@ -31,25 +33,3 @@ function verify() {
function configure_local_storage() {
echo "Local storage already configured ..."
}

function install_cdi {
_kubectl apply -f "./_out/manifests/release/cdi-operator.yaml"
}

function wait_cdi_crd_installed {
timeout=$1
crd_defined=0
while [ $crd_defined -eq 0 ] && [ $timeout > 0 ]; do
crd_defined=$(_kubectl get customresourcedefinition| grep cdis.cdi.kubevirt.io | wc -l)
sleep 1
timeout=timeout-1
done

#In case CDI crd is not defined after 120s - throw error
if [ $timeout \< 1 ]; then
echo "ERROR - CDI CRD is not defined after timeout"
exit 1
fi

}

1 change: 1 addition & 0 deletions cluster-sync/external/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CDI_INISTALL=${CDI_INSTALL_OPERATOR}
22 changes: 2 additions & 20 deletions cluster-sync/external/provider.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash

source cluster-sync/install.sh

function _kubectl(){
kubectl "$@"
}
Expand All @@ -21,24 +23,4 @@ function configure_local_storage() {
echo "Local storage not needed for external provider..."
}

function install_cdi {
_kubectl apply -f "./_out/manifests/release/cdi-operator.yaml"
}

function wait_cdi_crd_installed {
timeout=$1
crd_defined=0
while [ $crd_defined -eq 0 ] && [ $timeout > 0 ]; do
crd_defined=$(_kubectl get customresourcedefinition| grep cdis.cdi.kubevirt.io | wc -l)
sleep 1
timeout=timeout-1
done

#In case CDI crd is not defined after 120s - throw error
if [ $timeout \< 1 ]; then
echo "ERROR - CDI CRD is not defined after timeout"
exit 1
fi

}

51 changes: 51 additions & 0 deletions cluster-sync/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env bash

set -e
source ./cluster-sync/${KUBEVIRT_PROVIDER}/install.sh

function _kubectl(){
kubectl "$@"
}

function install_cdi_olm {
#Install CDI via OLM
_kubectl create ns $NAMESPACE
_kubectl apply -f _out/manifests/release/olm/operatorgroup.yaml
_kubectl apply -f _out/manifests/release/olm/k8s/cdi-catalogsource-registry.yaml
_kubectl apply -f _out/manifests/release/olm/k8s/cdi-subscription.yaml
}

function install_cdi_operator {
_kubectl apply -f "./_out/manifests/release/cdi-operator.yaml"
}


function install_cdi {
case "${CDI_INSTALL}" in
"${CDI_INSTALL_OPERATOR}")
install_cdi_operator
;;
"${CDI_INSTALL_OLM}")
install_cdi_olm
;;
esac
}


function wait_cdi_crd_installed {
timeout=$1
crd_defined=0
while [ $crd_defined -eq 0 ] && [ $timeout > 0 ]; do
crd_defined=$(_kubectl get customresourcedefinition| grep cdis.cdi.kubevirt.io | wc -l)
sleep 1
timeout=timeout-1
done

#In case CDI crd is not defined after 120s - throw error
if [ $timeout \< 1 ]; then
echo "ERROR - CDI CRD is not defined after timeout"
exit 1
fi

}

1 change: 1 addition & 0 deletions cluster-sync/k8s-1.13.3/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CDI_INSTALL=${CDI_INSTALL_OPERATOR}
1 change: 1 addition & 0 deletions cluster-sync/okd-4.1.0/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CDI_INSTALL=${CDI_INSTALL_OLM}
11 changes: 0 additions & 11 deletions cluster-sync/okd-4.1.0/provider.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,3 @@ function configure_local_storage() {
fi
}


function install_cdi {
#Install CDI via OLM
_kubectl create ns $NAMESPACE
_kubectl apply -f _out/manifests/release/olm/operatorgroup.yaml
_kubectl apply -f _out/manifests/release/olm/k8s/cdi-catalogsource-registry.yaml
_kubectl apply -f _out/manifests/release/olm/k8s/cdi-subscription.yaml
}



1 change: 1 addition & 0 deletions cluster-sync/os-3.11.0-crio/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CDI_INSTALL=${CDI_INSTALL_OPERATOR}
6 changes: 3 additions & 3 deletions cluster-sync/sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ _kubectl wait cdis.cdi.kubevirt.io/cdi --for=condition=running --timeout=120s
# Start functional test HTTP server.
# We skip the functional test additions for external provider for now, as they're specific
if [ "${KUBEVIRT_PROVIDER}" != "external" ]; then
_kubectl apply -f "./_out/manifests/file-host.yaml"
_kubectl apply -f "./_out/manifests/registry-host.yaml"
_kubectl apply -f "./_out/manifests/block-device.yaml"
_kubectl apply -f "./_out/manifests/file-host.yaml"
_kubectl apply -f "./_out/manifests/registry-host.yaml"
_kubectl apply -f "./_out/manifests/block-device.yaml"
fi
4 changes: 4 additions & 0 deletions cluster-up/hack/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ if [ -z "$KUBEVIRTCI_CONFIG_PATH" ]; then
)"
fi

CDI_INSTALL_OPERATOR="install-operator"
CDI_INSTALL_OLM="install-olm"
CDI_INSTALL=${CDI_INSTALL:-${CDI_INSTALL_OPERATOR}}

KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER:-k8s-1.13.3}
KUBEVIRT_NUM_NODES=${KUBEVIRT_NUM_NODES:-1}
KUBEVIRT_MEMORY_SIZE=${KUBEVIRT_MEMORY_SIZE:-5120M}
Expand Down
2 changes: 1 addition & 1 deletion doc/cdi-operator-olm.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# OLM (Operator Lifecycle Management) CDI (Containerized Data Importer) intergartion
# OLM (Operator Lifecycle Management) CDI (Containerized Data Importer) integration

## Table of Contents
* [OLM Overview](#overview)
Expand Down

0 comments on commit 8009b34

Please sign in to comment.