@@ -84,13 +84,32 @@ createRoleBindings () {
8484checkClusterRunning () {
8585
8686 echo " Confirm we have ${KUBERNETES_CLI:- kubectl} working..."
87- myline=` ${KUBERNETES_CLI:- kubectl} get nodes | awk ' {print $2}' | tail -n+2`
88- status=" NotReady"
89- max=50
90- count=1
91-
92- privateIP=${vcn_cidr_prefix// ./ \\ .} \\ .10\\ .
9387 privateIP=${vcn_cidr_prefix}
88+ myline_output=$( ${KUBERNETES_CLI:- kubectl} get nodes -o wide 2>&1 )
89+ if echo " $myline_output " | grep -q " Unable to connect to the server: net/http: TLS handshake timeout" ; then
90+ echo " [ERROR] Unable to connect to the server: net/http: TLS handshake timeout"
91+
92+ echo ' - could not talk to OKE cluster, aborting'
93+ cd ${terraformVarDir}
94+ terraform destroy -auto-approve -var-file=${terraformVarDir} /${clusterTFVarsFile} .tfvars
95+ terraform apply -auto-approve -var-file=${terraformVarDir} /${clusterTFVarsFile} .tfvars
96+ echo " retrying to execute KUBERNETES_CLI"
97+ clusterIP=$( oci ce cluster list --compartment-id=${compartment_ocid} | jq ' .data[] | select(."name" == ' " ${okeclustername} " ' and (."lifecycle-state" == "ACTIVE"))' | jq ' ."endpoints" | ."public-endpoint"' )
98+ echo " clusterIp : $clusterIP "
99+ clusterPublicIP=${clusterIP: 1:- 6}
100+ echo " clusterPublicIP : ${clusterPublicIP} "
101+ echo " NO_PROXY before : ${NO_PROXY} "
102+ export NO_PROXY=${clusterPublicIP}
103+ echo " NO_PROXY:" $NO_PROXY
104+ myline_output=$( ${KUBERNETES_CLI:- kubectl} get nodes -o wide 2>&1 )
105+ if echo " $myline_output " | grep -q " Unable to connect to the server: net/http: TLS handshake timeout" ; then
106+ echo " [ERROR] Unable to connect to the server: net/http: TLS handshake timeout"
107+ echo ' - could not talk to OKE cluster, aborting'
108+ cd ${terraformVarDir}
109+ terraform destroy -auto-approve -var-file=${terraformVarDir} /${clusterTFVarsFile} .tfvars
110+ exit 1
111+ fi
112+ fi
94113 declare -a myline
95114 myline=(` ${KUBERNETES_CLI:- kubectl} get nodes -o wide | grep " ${privateIP} " | awk ' {print $2}' ` )
96115 NODE_IP=` ${KUBERNETES_CLI:- kubectl} get nodes -o wide| grep " ${privateIP} " | awk ' {print $7}' `
@@ -116,7 +135,7 @@ checkClusterRunning () {
116135 if [ " $NODES " == " 2" ]; then
117136 echo ' - looks good'
118137 else
119- echo ' - could not talk to cluster, aborting'
138+ echo ' - could not talk to OKE cluster, aborting'
120139 cd ${terraformVarDir}
121140 terraform destroy -auto-approve -var-file=${terraformVarDir} /${clusterTFVarsFile} .tfvars
122141 exit 1
@@ -183,15 +202,15 @@ export KUBECONFIG=${terraformVarDir}/${okeclustername}_kubeconfig
183202export okeclustername=\" ${okeclustername} \"
184203
185204
186- echo " oci ce cluster list --compartment-id=${compartment_ocid} | jq '.data[] | select(." name" == '" ${okeclustername} " ' and (." lifecycle-state" == " ACTIVE" ))' | jq ' ." endpoints" | ." public-endpoint" '"
205+ echo " oci ce cluster list --compartment-id=${compartment_ocid} | jq '.data[] | select(." name" == '" ${okeclustername} " ' and (." lifecycle-state" == " ACTIVE" ))' | jq ' ." endpoints" | ." public-endpoint" '"
187206
188207clusterIP=$( oci ce cluster list --compartment-id=${compartment_ocid} | jq ' .data[] | select(."name" == ' " ${okeclustername} " ' and (."lifecycle-state" == "ACTIVE"))' | jq ' ."endpoints" | ."public-endpoint"' )
189208echo " clusterIp : $clusterIP "
190209clusterPublicIP=${clusterIP: 1:- 6}
191210echo " clusterPublicIP : ${clusterPublicIP} "
192- export NO_PROXY=$NO_PROXY ,${clusterPublicIP}
211+ echo " NO_PROXY before : ${NO_PROXY} "
212+ export NO_PROXY=${clusterPublicIP}
193213echo " NO_PROXY:" $NO_PROXY
194214
195-
196215checkClusterRunning
197216echo " $okeclustername is up and running}"
0 commit comments