setup-multus.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/usr/bin/env -S bash
  2. set -xeo pipefail
  3. # initially copied from https://github.com/k8snetworkplumbingwg/whereabouts
  4. MULTUS_DAEMONSET_URL="https://raw.githubusercontent.com/k8snetworkplumbingwg/multus-cni/master/deployments/multus-daemonset.yml"
  5. RETRY_MAX=10
  6. INTERVAL=10
  7. TIMEOUT=60
  8. TIMEOUT_K8="120s"
  9. retry() {
  10. local status=0
  11. local retries=${RETRY_MAX:=5}
  12. local delay=${INTERVAL:=5}
  13. local to=${TIMEOUT:=20}
  14. cmd="$*"
  15. while [ $retries -gt 0 ]; do
  16. status=0
  17. timeout $to bash -c "echo $cmd && $cmd" || status=$?
  18. if [ $status -eq 0 ]; then
  19. break
  20. fi
  21. echo "Exit code: '$status'. Sleeping '$delay' seconds before retrying"
  22. sleep $delay
  23. let retries--
  24. done
  25. return $status
  26. }
  27. echo "#### set up multus ####"
  28. echo " ## wait for coreDNS"
  29. kubectl -n kube-system wait --for=condition=available deploy/coredns --timeout=$TIMEOUT_K8
  30. echo "## install multus"
  31. retry kubectl create -f "${MULTUS_DAEMONSET_URL}"
  32. kubectl -n kube-system wait --for=condition=ready -l name="multus" pod --timeout=$TIMEOUT_K8
  33. echo "## install CNIs"
  34. retry kubectl create -f "https://raw.githubusercontent.com/k8snetworkplumbingwg/whereabouts/master/hack/cni-install.yml"
  35. kubectl -n kube-system wait --for=condition=ready -l name="cni-plugins" pod --timeout=$TIMEOUT_K8
  36. echo "## install whereabouts"
  37. kubectl create \
  38. -f https://raw.githubusercontent.com/k8snetworkplumbingwg/whereabouts/master/doc/crds/daemonset-install.yaml \
  39. -f https://raw.githubusercontent.com/k8snetworkplumbingwg/whereabouts/master/doc/crds/whereabouts.cni.cncf.io_ippools.yaml \
  40. -f https://raw.githubusercontent.com/k8snetworkplumbingwg/whereabouts/master/doc/crds/whereabouts.cni.cncf.io_overlappingrangeipreservations.yaml
  41. kubectl -n kube-system wait --for=condition=ready -l app=whereabouts pod --timeout=$TIMEOUT_K8
  42. echo "#### set up multus done ####"