-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from mattmattox/manager-worker
adding manager and worker
- Loading branch information
Showing
5 changed files
with
99 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM ubuntu:18.04 | ||
|
||
MAINTAINER [email protected] | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN apt-get update && apt-get install -yq --no-install-recommends \ | ||
apt-utils \ | ||
curl \ | ||
docker-ce-cli \ | ||
&& apt-get clean && rm -rf /var/lib/apt/lists/* | ||
|
||
## Install kubectl | ||
RUN curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" && chmod u+x kubectl && mv kubectl /usr/local/bin/kubectl | ||
|
||
## Setup run script | ||
WORKDIR /root | ||
ADD run.sh /root/run.sh | ||
|
||
CMD /root/run.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/bin/bash | ||
|
||
function check_node { | ||
current_status=`kubectl get node --no-headers "$1" |awk '{print $2}'` | ||
if [[ "$current_status" == "Ready" ]] || [[ "$current_status" == "Ready,SchedulingDisabled" ]] | ||
then | ||
return 0 | ||
else | ||
return 1 | ||
fi | ||
} | ||
|
||
if [[ -z $nodeTimeout ]] | ||
then | ||
nodeTimeout=60 | ||
fi | ||
echo "nodeTimeout: $nodeTimeout" | ||
|
||
echo "nodeName: $nodeName" | ||
if [[ -z "$nodeName" ]] | ||
then | ||
echo "Missing nodeName" | ||
exit 1 | ||
fi | ||
|
||
echo "Verifing Docker CLI access..." | ||
if ! docker info | ||
then | ||
echo "Problem accessing Docker CLI" | ||
exit 2 | ||
fi | ||
|
||
while true; | ||
do | ||
echo "Checking node status..." | ||
if check_node $nodeName | ||
then | ||
echo "Node is ready" | ||
else | ||
echo "Node is Not ready, rechecking..." | ||
count=0 | ||
while true | ||
do | ||
if ! check_node $nodeName | ||
then | ||
echo "Sleeping for $count seconds" | ||
sleep 1 | ||
count=$((count+1)) | ||
else | ||
echo "Node is now ready" | ||
break | ||
fi | ||
if [ $count -gt $nodeTimeout ] | ||
then | ||
echo "Node has been down for greater then $nodeTimeout seconds, assuming node is down" | ||
echo "Attempting node recovery" | ||
echo "Restarting kubelet" | ||
docker restart kubelet | ||
echo "Sleeping..." | ||
sleep 15 | ||
if check_node $nodeName | ||
then | ||
echo "Node has recovered" | ||
break | ||
fi | ||
fi | ||
done | ||
fi | ||
done |