Skip to content

Commit

Permalink
automation, cluster: Deploy Multus
Browse files Browse the repository at this point in the history
'kind.sh' script enable deploying Muluts, but there is no control which images
will be used, and its not possilbe to use chached images.
Once the cluster is deleted the image is discarded and pulled again next time the
cluster is created, which is wasteful.

Deploy Multus outside 'kind.sh' script, pull the images before creating the
cluster and store them in the the local registry.
Since the local registry data is backed by a container volume, all images are
persisted and will be reused next time the cluster is created.

Multus manifest is patched to use the local image tag, stored at the local
registry.

Export waiting for Kubevirt ready logic to enable deploying Multus & Kubevirt in
parallel, optimizing Multus & Kubevirt deployment time.

Signed-off-by: Or Mergi <[email protected]>
  • Loading branch information
ormergi committed Mar 3, 2024
1 parent bc4f286 commit ebfc4ad
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion automation/cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ KIND_LOCAL_REGISTRY_VOLUME="ovn-k8s"
OVN_IMAGE_REMOTE_TAG="ghcr.io/ovn-org/ovn-kubernetes/ovn-kube-f:master"
OVN_IMAGE_TAG="localhost:${KIND_LOCAL_REGISTRY_PORT}/ovn-org/ovn-kubernetes/ovn-kube-f:master"

MULTUS_VERSION="v4.0.2"

if [ ! -d ${OVN_K8S_REPO_PATH} ]; then
git clone ${OVN_K8S_REPO} --branch ${OVN_K8S_BRANCH} --single-branch ${OVN_K8S_REPO_PATH}
pushd ${OVN_K8S_REPO_PATH}
Expand Down Expand Up @@ -71,10 +73,35 @@ pull_ovn_k8s_image() {
fi
}

copy_image() {
if ! skopeo inspect --tls-verify=false "docker://${2}" &> /dev/null; then
skopeo copy --dest-tls-verify=false "docker://${1}" "docker://${2}"
fi
}

pull_multus_image() {
local -r remote_tag="ghcr.io/k8snetworkplumbingwg/multus-cni:${MULTUS_VERSION}"
local -r local_tag="localhost:${KIND_LOCAL_REGISTRY_PORT}/k8snetworkplumbingwg/multus-cni:${MULTUS_VERSION}"
copy_image "${remote_tag}" "${local_tag}"
}

deploy_multus() {
echo "Deploying Multus.."
curl -L "https://raw.githubusercontent.com/k8snetworkplumbingwg/multus-cni/${MULTUS_VERSION}/deployments/multus-daemonset.yml" | \
sed -e "s?ghcr.io?localhost:${KIND_LOCAL_REGISTRY_PORT}?g" -e "s?:snapshot?:${MULTUS_VERSION}?g" | \
kubectl apply -f -
}

wait_for_multus_ready() {
echo "Waiting for Multus to become ready.."
kubectl rollout status -n kube-system ds/kube-multus-ds --timeout=10m
}

cluster_up() {
setup_local_registry

pull_ovn_k8s_image
pull_multus_image

(
cd "${OVN_K8S_KIND}"
Expand All @@ -84,9 +111,14 @@ cluster_up() {
--num-workers 0 \
--local-kind-registry \
--ovn-image ${OVN_IMAGE_TAG} \
--multi-network-enable \
$(NULL)
)

export KUBECONFIG=~/ovn.conf

deploy_multus

wait_for_multus_ready
}

cluster_down() {
Expand Down

0 comments on commit ebfc4ad

Please sign in to comment.