diff --git a/hack/e2e-kind-cluster-setup.sh b/hack/e2e-kind-cluster-setup.sh index f94e266e..ab9822c3 100755 --- a/hack/e2e-kind-cluster-setup.sh +++ b/hack/e2e-kind-cluster-setup.sh @@ -1,8 +1,13 @@ #!/bin/bash set -xe +CLUSTER_TYPE=${CLUSTER_TYPE:-kind} +SKIP_MULTUS_DEPLOYMENT=${SKIP_MULTUS_DEPLOYMENT:-false} +MULTUS_VERSION=${MULTUS_VERSION:-latest} + CNI_VERSION=${CNI_VERSION:-0.4.0} OCI_BIN=${OCI_BIN:-docker} +CRI=${CRI:-"containerd"} # possible values: containerd / crio IMG_REGISTRY=${IMAGE_REGISTRY:-localhost:5000/k8snetworkplumbingwg} IMG_TAG="e2e" @@ -25,7 +30,12 @@ setup_cluster() { push_local_image() { OCI_BIN="$OCI_BIN" IMAGE_REGISTRY="$IMG_REGISTRY" IMAGE_TAG="$IMG_TAG" make manifests OCI_BIN="$OCI_BIN" IMAGE_REGISTRY="$IMG_REGISTRY" IMAGE_TAG="$IMG_TAG" make img-build - kind load docker-image $IMG_REGISTRY/multus-dynamic-networks-controller:$IMG_TAG + + if [[ $CLUSTER_TYPE == "kind" ]]; then + kind load docker-image $IMG_REGISTRY/multus-dynamic-networks-controller:$IMG_TAG + else + "$OCI_BIN" push $IMG_REGISTRY/multus-dynamic-networks-controller:$IMG_TAG + fi } cleanup() { @@ -33,10 +43,34 @@ cleanup() { git checkout -- manifests/ } +install_specific_multus_version() { + if [[ $MULTUS_VERSION == "latest" ]]; then + echo "error: MULTUS_VERSION is required to be a specific version (i.e v4.1.2), not 'latest' when using non kind provider" + exit 1 + fi + + echo "Installing multus-cni $MULTUS_VERSION daemonset ..." + wget -qO- "https://raw.githubusercontent.com/k8snetworkplumbingwg/multus-cni/${MULTUS_VERSION}/deployments/multus-daemonset-thick.yml" |\ + sed -e "s|multus-cni:snapshot|multus-cni:${MULTUS_VERSION}|g" |\ + kubectl apply -f - +} + trap "cleanup" EXIT -git clone https://github.com/k8snetworkplumbingwg/multus-cni/ -start_registry_container -setup_cluster + +if [[ $CLUSTER_TYPE == "kind" ]]; then + git clone https://github.com/k8snetworkplumbingwg/multus-cni/ + start_registry_container + setup_cluster +elif [[ $SKIP_MULTUS_DEPLOYMENT != true ]]; then + install_specific_multus_version +fi + push_local_image -kubectl apply -f manifests/dynamic-networks-controller.yaml + +if [[ $CRI == "containerd" ]]; then + kubectl apply -f manifests/dynamic-networks-controller.yaml +else + kubectl apply -f manifests/crio-dynamic-networks-controller.yaml +fi + kubectl wait -nkube-system --for=condition=ready --timeout=180s -l app=dynamic-networks-controller pods