Upgrade Calico to v3.24.3
[iec.git] / src / foundation / scripts / cni / multus / multus-sriov-flannel / install.sh
1 #!/bin/bash -ex
2 # shellcheck disable=SC2016,SC2046
3
4 #SCRIPTS_DIR=$(dirname "${BASH_SOURCE[0]}")
5
6 function wait_for {
7   # Execute in a subshell to prevent local variable override during recursion
8   (
9     local total_attempts=$1; shift
10     local cmdstr=$*
11     local sleep_time=2
12     echo -e "\n[wait_for] Waiting for cmd to return success: ${cmdstr}"
13     # shellcheck disable=SC2034
14     for attempt in $(seq "${total_attempts}"); do
15       echo "[wait_for] Attempt ${attempt}/${total_attempts%.*} for: ${cmdstr}"
16       # shellcheck disable=SC2015
17       eval "${cmdstr}" && echo "[wait_for] OK: ${cmdstr}" && return 0 || true
18       sleep "${sleep_time}"
19     done
20     echo "[wait_for] ERROR: Failed after max attempts: ${cmdstr}"
21     return 1
22   )
23 }
24
25
26 kubectl create -f configMap.yaml
27 wait_for 5 'test $(kubectl get configmap -n kube-system | grep sriovdp-config -c ) -eq 1'
28
29 kubectl create -f multus-sriov-flannel-daemonsets.yaml
30 wait_for 100 'test $(kubectl get pods -n kube-system | grep -e "kube-multus-ds" | grep "Running" -c) -ge 1'
31 wait_for 20 'test $(kubectl get pods -n kube-system | grep -e "kube-sriov-cni" | grep "Running" -c) -ge 1'
32 wait_for 20 'test $(kubectl get pods -n kube-system | grep -e "kube-sriov-device-plugin" | grep "Running" -c) -ge 1'
33
34 kubectl create -f flannel-daemonset.yml
35 wait_for 100 'test $(kubectl get pods -n kube-system | grep -e "kube-flannel-ds" | grep "Running" -c) -ge 1'
36
37 kubectl create -f sriov-crd.yaml
38 wait_for 5 'test $(kubectl get crd | grep -e "network-attachment-definitions" -c) -ge 1'
39
40
41 kubectl get node $(hostname) -o json | jq '.status.allocatable'