@@ -4,10 +4,10 @@ EXTERNAL_IP=$(curl -s -m 10 http://whatismyip.akamai.com/)
44NAMESPACE=$( echo -n " ${domain_name} "   |  sed " s/\.oraclevcn\.com//g" ) 
55FQDN_HOSTNAME=$( getent hosts $( ip route get 1 |  awk ' {print $NF;exit}' )   |  awk ' {print $2}' ) 
66
7- #  pull  instance metadata
7+ #  Pull  instance metadata
88curl -sL --retry 3 http://169.254.169.254/opc/v1/instance/ |  tee /tmp/instance_meta.json
99
10- # # create  policy file that blocks autostart of services on install
10+ # # Create  policy file that blocks autostart of services on install
1111printf  ' #!/bin/sh\necho "All runlevel operations denied by policy" >&2\nexit 101\n'   > /tmp/policy-rc.d &&  chmod +x /tmp/policy-rc.d
1212export  K8S_API_SERVER_LB=${master_lb} 
1313export  ETCD_LB=${etcd_lb} 
@@ -19,14 +19,16 @@ export IP_LOCAL=$(ip route show to 0.0.0.0/0 | awk '{ print $5 }' | xargs ip add
1919SUBNET=$( getent hosts $IP_LOCAL  |  awk ' {print $2}'   |  cut -d. -f2) 
2020export  WORKER_IP=$IP_LOCAL 
2121
22- # # download etcdctl client 
22+ # # etcd 
2323# #####################################
24+ 
25+ #  Download etcdctl client
2426curl -L --retry 3 https://github.com/coreos/etcd/releases/download/${etcd_ver} /etcd-${etcd_ver} -linux-amd64.tar.gz -o /tmp/etcd-${etcd_ver} -linux-amd64.tar.gz
2527tar zxf /tmp/etcd-${etcd_ver} -linux-amd64.tar.gz -C /tmp/ &&  cp /tmp/etcd-${etcd_ver} -linux-amd64/etcd*  /usr/local/bin/
2628
27- #  wait  for etcd to become active (through the LB)
29+ #  Wait  for etcd to become active (through the LB)
2830until  [ $( /usr/local/bin/etcdctl --endpoints ${etcd_lb}  cluster-health |  grep ' ^cluster '   |  grep -c ' is healthy$' )   ==  " 1"   ];  do 
29- 	echo  " Waiting for cluster to be healthy" 
31+ 	echo  " Waiting for etcd  cluster to be healthy" 
3032	sleep 1
3133done 
3234
@@ -39,47 +41,21 @@ echo "IP_LOCAL: $IP_LOCAL ETCD_SERVER: $ETCD_SERVER"
3941envsubst < /root/services/flannel.service > /etc/systemd/system/flannel.service
4042systemctl daemon-reload &&  systemctl enable  flannel &&  systemctl start flannel
4143
42- # # INSTALL CNI PLUGIN 
44+ # # Create cni bridge interface w/ IP from flannel 
4345# #####################################
44- mkdir -p /opt/cni/bin /etc/cni/net.d
45- curl -L --retry 3 https://github.com/containernetworking/cni/releases/download/v0.5.2/cni-amd64-v0.5.2.tgz -o /tmp/cni-plugin.tar.gz
46- tar zxf /tmp/cni-plugin.tar.gz -C /opt/cni/bin/
47- printf  ' {\n    "name": "podnet",\n    "type": "flannel",\n    "delegate": {\n        "isDefaultGateway": true\n    }\n}\n'   > /etc/cni/net.d/10-flannel.conf
4846cp /root/services/cni-bridge.service /etc/systemd/system/cni-bridge.service
4947cp /root/services/cni-bridge.sh /usr/local/bin/cni-bridge.sh &&  chmod +x /usr/local/bin/cni-bridge.sh
5048systemctl enable  cni-bridge &&  systemctl start cni-bridge
5149
52- # ##################################### DOCKER ######################################
53- 
54- # # Install Docker prereqs
50+ # # Docker
5551# #####################################
56- until  yum -y install aufs-tools cgroupfs-mount libltdl7 unzip;  do  sleep &&  echo  -n " ." ;  done 
57- 
58- #  Stage worker certs
59- unzip /tmp/k8s-certs.zip -d /etc/kubernetes/ssl/
60- 
61- #  enable ol7 addons
62- yum-config-manager --disable ol7_UEKR3
63- yum-config-manager --enable ol7_addons ol7_latest ol7_UEKR4 ol7_optional ol7_optional_latest
64- 
65- #  Install Docker
6652until  yum -y install docker-engine-${docker_ver} ;  do  sleep 1 &&  echo  -n " ." ;  done 
67- systemctl stop docker
68- 
69- #  Disable irqbalance for performance
70- service irqbalance stop
71- yum -y erase irqbalance
7253
54+ #  Configure Docker to use flannel
7355rm -f /lib/systemd/system/docker.service &&  cat /root/services/docker.service > /lib/systemd/system/docker.service
74- systemctl enable  docker
7556systemctl daemon-reload
76- systemctl restart docker
77- 
78- 
79- # # Add default DNS
80- # #####################################
81- echo  " nameserver 169.254.169.254"   >> /etc/resolvconf/resolv.conf.d/base
82- resolvconf -u
57+ systemctl enable  docker
58+ systemctl start docker
8359
8460# # Output /etc/environment_params
8561# #####################################
@@ -92,7 +68,6 @@ echo "FQDN_HOSTNAME=$FQDN_HOSTNAME" >>/etc/environment_params
9268# #####################################
9369iptables -F
9470
95- 
9671cat << EOF  > /etc/yum.repos.d/kubernetes.repo
9772[kubernetes] 
9873name=Kubernetes 
@@ -109,17 +84,22 @@ setenforce 0
10984systemctl stop firewalld.service
11085systemctl disable firewalld.service
11186
87+ #  Configure pod network:
88+ mkdir -p /etc/cni/net.d
89+ cat > /etc/cni/net.d/10-flannel.conf << EOF 
90+ { 
91+ 	"name": "podnet", 
92+ 	"type": "flannel", 
93+ 	"delegate": { 
94+ 		"isDefaultGateway": true 
95+ 	} 
96+ } 
97+ EOF 
98+ 
11299# # Install kubelet, kubectl, and kubernetes-cni
113100# ##############################################
114101yum-config-manager --add-repo http://yum.kubernetes.io/repos/kubernetes-el7-x86_64
115- until  yum install -y kubelet-${k8s_ver} -0 kubectl-${k8s_ver} -0;  do  sleep 1 &&  echo  -n " ." ; done 
116- 
117- until  systemctl stop kubelet;  do  sleep 1;  done 
118- mkdir -p /opt/cni/bin /etc/cni/net.d
119- tar zxf /tmp/cni-plugin.tar.gz -C /opt/cni/bin/
120- printf  ' {\n    "name": "podnet",\n    "type": "flannel",\n    "delegate": {\n        "isDefaultGateway": true\n    }\n}\n'   > /etc/cni/net.d/10-flannel.conf
121- 
122- # ##################################### ETCD ######################################
102+ until  yum install -y kubelet-${k8s_ver} -0 kubectl-${k8s_ver} -0 kubernetes-cni;  do  sleep 1 &&  echo  -n " ." ; done 
123103
124104# # Pull etcd docker image from registry
125105docker pull quay.io/coreos/etcd:${etcd_ver} 
@@ -140,9 +120,8 @@ docker run -d \
140120sed -e " s/__FQDN_HOSTNAME__/$FQDN_HOSTNAME /g"   /etc/kubernetes/manifests/kube-proxy.yaml > /tmp/kube-proxy.yaml
141121cat /tmp/kube-proxy.yaml > /etc/kubernetes/manifests/kube-proxy.yaml
142122
143- # # Kubelet  for the worker
123+ # # kubelet  for the worker
144124# #####################################
145- rm /lib/systemd/system/kubelet.service
146125systemctl daemon-reload
147126
148127AVAILABILITY_DOMAIN=$( jq -r ' .availabilityDomain'   /tmp/instance_meta.json |  sed ' s/:/-/g' ) 
@@ -160,7 +139,7 @@ sed -e "s/__FQDN_HOSTNAME__/$FQDN_HOSTNAME/g" \
160139    -e " s/__NODE_SHAPE__/$NODE_SHAPE /g"   \
161140    /root/services/kubelet.service >  /etc/systemd/system/kubelet.service
162141
163- # # wait  for k8smaster  to be available. possible race on pod networks otherwise
142+ # # Wait  for k8s master  to be available. There is a  possible race on pod networks otherwise. 
164143until  [ " $( curl -k --cert /etc/kubernetes/ssl/apiserver.pem --key /etc/kubernetes/ssl/apiserver-key.pem $K8S_API_SERVER_LB /healthz 2> /dev/null) "   ==  " ok"   ];  do 
165144	sleep 3
166145done 
0 commit comments