Skip to content

Commit

Permalink
cluster: Allow deploying on external cluster
Browse files Browse the repository at this point in the history
Allows to deploy Multus dynamic networks controller on external provider.
Deploys fixed multus release (doesnt build latest as this repo usually do).

Usage:

export CLUSTER_TYPE=external
export KUBECONFIG=<kubeconfig>
export IMAGE_REGISTRY=quay.io/<your_quay>
export MULTUS_VERSION=v4.1.1

If CRIO is used, use export CRI=crio (works also for non external clusters).

If You don't want to deploy multus at all use (you must deploy it yourself as the controller depends on it)
export SKIP_MULTUS_DEPLOYMENT=true (supported only for external clusters)

Signed-off-by: Or Shoval <[email protected]>
  • Loading branch information
oshoval authored and maiqueb committed Nov 7, 2024
1 parent e328aeb commit 84cf644
Showing 1 changed file with 39 additions and 5 deletions.
44 changes: 39 additions & 5 deletions hack/e2e-kind-cluster-setup.sh
Original file line number Diff line number Diff line change
@@ -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"

Expand All @@ -25,18 +30,47 @@ 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() {
rm -rf multus-cni
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

0 comments on commit 84cf644

Please sign in to comment.