4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
19 echo "Waiting for file $1"
25 CERT_AUTH="/etc/openssl/ca.pem"
26 CLIENT_CER="/etc/kubernetes/ssl/kubelet-server.pem"
27 CLIENT_KEY="/etc/kubernetes/ssl/kubelet-server-key.pem"
28 wait_for_file $CERT_AUTH
29 wait_for_file $CLIENT_CER
30 wait_for_file $CLIENT_KEY
38 if [[ "$keepdoing" == "true" ]]
40 echo "Waiting for kubernetes node to become ready..."
41 uncordon_ready=$( /usr/bin/kubectl get node --show-labels | grep -i "{{ nodename }}" | grep -i "ready" | grep -i "SchedulingDisabled" | wc -l )
42 if [[ "$uncordon_ready" -eq "1" ]]
45 /usr/bin/kubectl uncordon {{ ansible_host }} || echo "Post start kubelet, this node was never cordoned."
46 echo "Node uncordoned, and ready!"
48 node_ready=$( /usr/bin/kubectl get node --show-labels | grep -i "{{ nodename }}" | grep -i " ready " | wc -l )
49 if [[ "$node_ready" -eq "1" ]]
52 echo "Node become ready."
56 result="$(wget --timeout 10 --tries 5 --ca-certificate $CERT_AUTH --certificate $CLIENT_CER --private-key $CLIENT_KEY --spider https://{{ ansible_host }}:10250/healthz 2>&1 | grep 'HTTP' | grep -E -o '[[:digit:]]{3}')"
59 if [ "$result" == "200" ]
61 echo "Healtcheck success"
64 echo "Healtcheck failed"
67 if [ "$error" -ge "5" ]
69 echo "Error with kubelet (Healtcheck failed 5 times) restarting it"
70 systemctl restart kubelet.service