#!/usr/bin/env -S bash set -xeo pipefail # initially copied from https://github.com/k8snetworkplumbingwg/whereabouts MULTUS_DAEMONSET_URL="https://raw.githubusercontent.com/k8snetworkplumbingwg/multus-cni/master/deployments/multus-daemonset.yml" RETRY_MAX=10 INTERVAL=10 TIMEOUT=60 # image pulls plus CNI bootstrap across all nodes can take a few minutes on # busy CI runners; the waits below return as soon as the rollouts are ready TIMEOUT_K8="300s" retry() { local status=0 local retries=${RETRY_MAX:=5} local delay=${INTERVAL:=5} local to=${TIMEOUT:=20} cmd="$*" while [ $retries -gt 0 ]; do status=0 timeout $to bash -c "echo $cmd && $cmd" || status=$? if [ $status -eq 0 ]; then break fi echo "Exit code: '$status'. Sleeping '$delay' seconds before retrying" sleep $delay let retries-- done return $status } echo "#### set up multus ####" echo " ## wait for coreDNS" kubectl -n kube-system wait --for=condition=available deploy/coredns --timeout=$TIMEOUT_K8 echo "## install multus" retry kubectl create -f "${MULTUS_DAEMONSET_URL}" # use 'rollout status' on the daemonset instead of 'kubectl wait' on a pod # label selector: right after 'kubectl create' the daemonset controller may # not have created any pods yet, and 'kubectl wait' exits immediately with # "no matching resources found" when the selector matches nothing kubectl -n kube-system rollout status daemonset/kube-multus-ds --timeout=$TIMEOUT_K8 echo "## install CNIs" retry kubectl create -f "https://raw.githubusercontent.com/k8snetworkplumbingwg/whereabouts/master/hack/cni-install.yml" kubectl -n kube-system rollout status daemonset/install-cni-plugins --timeout=$TIMEOUT_K8 echo "## install whereabouts" kubectl create \ -f https://raw.githubusercontent.com/k8snetworkplumbingwg/whereabouts/master/doc/crds/daemonset-install.yaml \ -f https://raw.githubusercontent.com/k8snetworkplumbingwg/whereabouts/master/doc/crds/whereabouts.cni.cncf.io_ippools.yaml \ -f https://raw.githubusercontent.com/k8snetworkplumbingwg/whereabouts/master/doc/crds/whereabouts.cni.cncf.io_overlappingrangeipreservations.yaml kubectl -n kube-system rollout status daemonset/whereabouts --timeout=$TIMEOUT_K8 echo "#### set up multus done ####"