Skip to content

Commit

Permalink
Enhance liveness check with @razee/kubernetes-util (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkingit authored and alewitt2 committed Aug 1, 2019
1 parent 8d16e3d commit 1e31e97
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 23 deletions.
2 changes: 1 addition & 1 deletion kubernetes/RemoteResource/resource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ items:
command:
- sh/liveness.sh
initialDelaySeconds: 30
periodSeconds: 300
periodSeconds: 150
timeoutSeconds: 30
failureThreshold: 1
volumeMounts:
Expand Down
60 changes: 41 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"license": "Apache-2.0",
"dependencies": {
"@razee/kapitan-core": "^0.3.0",
"@razee/kubernetes-util": "0.0.4",
"@razee/kubernetes-util": "0.0.6",
"bunyan": "^1.8.12",
"clone": "^2.1.2",
"request-promise-native": "^1.0.7"
Expand Down
15 changes: 14 additions & 1 deletion sh/liveness.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,17 @@
# limitations under the License.
################################################################################

exit 0
HEALTH_FILE=/tmp/liveness
AGE=${1:-'5'} #Default 5 minutes

findFile=$(find "${HEALTH_FILE}" -mmin "-${AGE}" 2>/dev/null)
if [ $? -ne 0 ]; then
echo "FAILING liveness probe. ${HEALTH_FILE} does not exist."
exit 1
elif [ "${findFile}" = "" ]; then
echo "FAILING liveness probe. ${HEALTH_FILE} has not been touched in ${AGE} minutes."
exit 1
else
# echo "file is good"
exit 0
fi
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ async function main() {
kubeResourceMeta: resourceMeta,
factory: Controller,
kubeClass: kc,
logger: log
logger: log,
livenessInterval:true
};
new EventHandler(params);
} else {
Expand Down

0 comments on commit 1e31e97

Please sign in to comment.