Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 68ba01d

Browse files
author
Kubernetes Submit Queue
authored
Merge pull request #35308 from vmware/automated-cherry-pick-of-#35232-upstream-release-1.4
Automatic merge from submit-queue Wait for cbr0 configuration to complete before setting up routes. - f… Automated cherry pick of #35232 , this is needed for kube-up to work on vSphere, need this in the next 1.4 release. fixes #34248, #31310 - Remove optimizations for salt status check till flakyness of install is addressed - fix indentation
2 parents 07a8c55 + 4ae7d7c commit 68ba01d

2 files changed

Lines changed: 41 additions & 12 deletions

File tree

cluster/vsphere/config-default.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ MASTER_MEMORY_MB=1024
2828
MASTER_CPU=1
2929

3030
NODE_NAMES=($(eval echo ${INSTANCE_PREFIX}-minion-{1..${NUM_NODES}}))
31-
NODE_IP_RANGES="10.244.0.0/16"
31+
NODE_IP_RANGES="10.244.0.0/16" # Min Prefix supported is 16
3232
MASTER_IP_RANGE="${MASTER_IP_RANGE:-10.246.0.0/24}"
3333
NODE_MEMORY_MB=2048
3434
NODE_CPU=1

cluster/vsphere/util.sh

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -325,23 +325,52 @@ function setup-pod-routes {
325325
# identify the subnet assigned to the node by the kubernertes controller manager.
326326
KUBE_NODE_BRIDGE_NETWORK=()
327327
for (( i=0; i<${#NODE_NAMES[@]}; i++)); do
328-
printf " finding network of cbr0 bridge on node ${NODE_NAMES[$i]}\n"
329-
network=$(kube-ssh ${KUBE_NODE_IP_ADDRESSES[$i]} 'sudo ip route show | grep -E "dev cbr0" | cut -d " " -f1')
330-
KUBE_NODE_BRIDGE_NETWORK+=("${network}")
331-
done
328+
printf " finding network of cbr0 bridge on node ${NODE_NAMES[$i]}\n"
329+
330+
network=""
331+
top2_octets_final=$(echo $NODE_IP_RANGES | awk -F "." '{ print $1 "." $2 }') # Assume that a 24 bit mask per node
332+
333+
attempt=0
334+
max_attempt=60
335+
while true ; do
336+
attempt=$(($attempt+1))
337+
338+
network=$(kube-ssh ${KUBE_NODE_IP_ADDRESSES[$i]} 'sudo ip route show | grep -E "dev cbr0" | cut -d " " -f1')
339+
top2_octets_read=$(echo $network | awk -F "." '{ print $1 "." $2 }')
340+
341+
if [[ "$top2_octets_read" == "$top2_octets_final" ]]; then
342+
break
343+
fi
344+
345+
if (( $attempt == $max_attempt )); then
346+
echo
347+
echo "(Failed) Waiting for cbr0 bridge to come up @ ${NODE_NAMES[$i]}"
348+
echo
349+
exit 1
350+
fi
332351

352+
printf "."
353+
sleep 5
354+
done
355+
356+
printf "\n"
357+
KUBE_NODE_BRIDGE_NETWORK+=("${network}")
358+
done
333359

334360
# Make the pods visible to each other and to the master.
335361
# The master needs have routes to the pods for the UI to work.
336362
local j
337363
for (( i=0; i<${#NODE_NAMES[@]}; i++)); do
338-
printf "setting up routes for ${NODE_NAMES[$i]}"
339-
kube-ssh "${KUBE_MASTER_IP}" "sudo route add -net ${KUBE_NODE_BRIDGE_NETWORK[${i}]} gw ${KUBE_NODE_IP_ADDRESSES[${i}]}"
340-
for (( j=0; j<${#NODE_NAMES[@]}; j++)); do
341-
if [[ $i != $j ]]; then
342-
kube-ssh ${KUBE_NODE_IP_ADDRESSES[$i]} "sudo route add -net ${KUBE_NODE_BRIDGE_NETWORK[$j]} gw ${KUBE_NODE_IP_ADDRESSES[$j]}"
343-
fi
344-
done
364+
printf "setting up routes for ${NODE_NAMES[$i]}\n"
365+
printf " adding route to ${MASTER_NAME} for network ${KUBE_NODE_BRIDGE_NETWORK[${i}]} via ${KUBE_NODE_IP_ADDRESSES[${i}]}\n"
366+
kube-ssh "${KUBE_MASTER_IP}" "sudo route add -net ${KUBE_NODE_BRIDGE_NETWORK[${i}]} gw ${KUBE_NODE_IP_ADDRESSES[${i}]}"
367+
for (( j=0; j<${#NODE_NAMES[@]}; j++)); do
368+
if [[ $i != $j ]]; then
369+
printf " adding route to ${NODE_NAMES[$j]} for network ${KUBE_NODE_BRIDGE_NETWORK[${i}]} via ${KUBE_NODE_IP_ADDRESSES[${i}]}\n"
370+
kube-ssh ${KUBE_NODE_IP_ADDRESSES[$i]} "sudo route add -net ${KUBE_NODE_BRIDGE_NETWORK[$j]} gw ${KUBE_NODE_IP_ADDRESSES[$j]}"
371+
fi
372+
done
373+
printf "\n"
345374
done
346375
}
347376

0 commit comments

Comments
 (0)