2023-11-17 01:37:05 +01:00
|
|
|
#!/usr/bin/env -S bash
|
2023-05-24 15:14:21 -06:00
|
|
|
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
|
2026-06-10 16:54:24 -07:00
|
|
|
# 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"
|
2023-05-24 15:14:21 -06:00
|
|
|
|
|
|
|
|
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}"
|
2026-06-10 16:54:24 -07:00
|
|
|
# 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
|
2023-05-24 15:14:21 -06:00
|
|
|
|
|
|
|
|
echo "## install CNIs"
|
|
|
|
|
retry kubectl create -f "https://raw.githubusercontent.com/k8snetworkplumbingwg/whereabouts/master/hack/cni-install.yml"
|
2026-06-10 16:54:24 -07:00
|
|
|
kubectl -n kube-system rollout status daemonset/install-cni-plugins --timeout=$TIMEOUT_K8
|
2023-05-24 15:14:21 -06:00
|
|
|
|
|
|
|
|
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
|
2026-06-10 16:54:24 -07:00
|
|
|
kubectl -n kube-system rollout status daemonset/whereabouts --timeout=$TIMEOUT_K8
|
2023-05-24 15:14:21 -06:00
|
|
|
|
|
|
|
|
echo "#### set up multus done ####"
|