@@ -84,13 +84,32 @@ createRoleBindings () {
84
84
checkClusterRunning () {
85
85
86
86
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\\ .
93
87
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
94
113
declare -a myline
95
114
myline=(` ${KUBERNETES_CLI:- kubectl} get nodes -o wide | grep " ${privateIP} " | awk ' {print $2}' ` )
96
115
NODE_IP=` ${KUBERNETES_CLI:- kubectl} get nodes -o wide| grep " ${privateIP} " | awk ' {print $7}' `
@@ -116,7 +135,7 @@ checkClusterRunning () {
116
135
if [ " $NODES " == " 2" ]; then
117
136
echo ' - looks good'
118
137
else
119
- echo ' - could not talk to cluster, aborting'
138
+ echo ' - could not talk to OKE cluster, aborting'
120
139
cd ${terraformVarDir}
121
140
terraform destroy -auto-approve -var-file=${terraformVarDir} /${clusterTFVarsFile} .tfvars
122
141
exit 1
@@ -183,15 +202,15 @@ export KUBECONFIG=${terraformVarDir}/${okeclustername}_kubeconfig
183
202
export okeclustername=\" ${okeclustername} \"
184
203
185
204
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" '"
187
206
188
207
clusterIP=$( oci ce cluster list --compartment-id=${compartment_ocid} | jq ' .data[] | select(."name" == ' " ${okeclustername} " ' and (."lifecycle-state" == "ACTIVE"))' | jq ' ."endpoints" | ."public-endpoint"' )
189
208
echo " clusterIp : $clusterIP "
190
209
clusterPublicIP=${clusterIP: 1:- 6}
191
210
echo " clusterPublicIP : ${clusterPublicIP} "
192
- export NO_PROXY=$NO_PROXY ,${clusterPublicIP}
211
+ echo " NO_PROXY before : ${NO_PROXY} "
212
+ export NO_PROXY=${clusterPublicIP}
193
213
echo " NO_PROXY:" $NO_PROXY
194
214
195
-
196
215
checkClusterRunning
197
216
echo " $okeclustername is up and running}"
0 commit comments