@@ -6,15 +6,15 @@ pip install netaddr
66
77source /etc/profile.d/cluster
88
9- name=" $( echo $MY_IPADDRESS | perl -pe ' s{\.}{}g' ) "
109all_nets=" $( python ./lib/generate_network_blocks.py --master-cidr-block ${KUBE_NODE_IP_CIDRS} --cidr-divider ${KUBE_NODE_IP_CIDRS_SUBDIVIDER} ) "
11-
10+ num_nets= " $( echo $all_nets | awk ' {print NF} ' ) "
1211asg_addresses=$( echo " $CLUSTER_ADDRESSES , $MY_IPADDRESS " | perl -pe ' s{,}{}g; s{ }{\n}g' | sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n)
12+ num_members=" $( echo $asg_addresses | awk ' {print NF}' ) "
1313
1414my_location_in_list=0
1515for ip in $asg_addresses ; do
1616 if [ " $ip " = " $MY_IPADDRESS " ]; then
17- break ;
17+ break ;
1818 fi
1919 my_location_in_list=$(( my_location_in_list + 1 ))
2020done
2727
2828 DOCKER_BIP=
2929 net_counter=1
30- for aNet in $all_nets ; do
31- if [ $(( net_counter% 3 )) = $my_location_in_list ]; then
32- unused=true
33- for uNet in $used_nets ; do
34- if [ " $uNet " = " $aNet " ]; then
35- unused=false
36- fi
37- done
38-
39- if [ $unused = true ]; then
40- DOCKER_BIP=" $aNet "
41- break
42- fi
43- fi
44- net_counter=$(( net_counter + 1 ))
30+ while [ $num_members -gt 0 ]; do
31+ for aNet in $all_nets ; do
32+ if [ $(( net_counter% num_members)) = $my_location_in_list ]; then
33+ unused=true
34+ for uNet in $used_nets ; do
35+ if [ " $uNet " = " $aNet " ]; then
36+ unused=false
37+ fi
38+ done
39+
40+ if [ $unused = true ]; then
41+ DOCKER_BIP=" $aNet "
42+ break
43+ fi
44+ fi
45+ net_counter=$(( net_counter + 1 ))
46+ done
47+ if [ " ${DOCKER_BIP:- } " = " " -a " $num_members " = " 0" ]; then
48+ echo " no more net space open - exiting"
49+ exit 1
50+ fi
51+ if [ " ${DOCKER_BIP:- } " != " " ]; then
52+ break ;
53+ fi
54+ num_members=$(( num_members - 1 ))
4555 done
46- # # lets add 1 to the net
56+ # # lets add 1 to the net
4757 baseaddr=" $( echo $DOCKER_BIP | cut -d. -f1-3) "
4858 lsv=" $( echo $DOCKER_BIP | cut -d. -f4) "
4959 docker_bind=" $baseaddr .$(( lsv + 1 )) "
5060
51- # # docker config
61+ # # docker config
5262 cat << EOF > /etc/sysconfig/docker
5363# The max number of open files for the daemon itself, and all
5464# running containers. The default value of 1048576 mirrors the value
0 commit comments