Skip to content

Commit

Permalink
Added more on liveness probe
Browse files Browse the repository at this point in the history
Signed-off-by: knrt10 <tripathi.kautilya@gmail.com>
  • Loading branch information
knrt10 committed Dec 9, 2019
1 parent e00b3cf commit 04d581d
Show file tree
Hide file tree
Showing 7 changed files with 269 additions and 181 deletions.
173 changes: 0 additions & 173 deletions 1.docker/readme.md

This file was deleted.

4 changes: 2 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const http = require('http');
const os = require('os');
console.log("Kubia server starting...");
var handler = function (request, response) {
let handler = function (request, response) {
console.log("Received request from " + request.connection.remoteAddress);
response.writeHead(200);
response.end("You've hit " + os.hostname() + "\n");
};
var www = http.createServer(handler);
let www = http.createServer(handler);
www.listen(8080);
12 changes: 12 additions & 0 deletions kubia-liveness-probe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: pod
metadata:
name: kubia-liveness
spec:
containers:
- image: knrt10/kubia-unhealthy
name: kubia
livenessProbe:
httpGet:
path: /
port: 8080
5 changes: 5 additions & 0 deletions kubia-unhealthy/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM node:8

ADD app.js /app.js

ENTRYPOINT [ "node", "app.js" ]
21 changes: 21 additions & 0 deletions kubia-unhealthy/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const http = require('http');
const os = require('os');

console.log("Kubia server starting...");

let requestCount = 0;

let handler = function(request, response) {
console.log("Received request from " + request.connection.remoteAddress);
requestCount++;
if (requestCount > 5) {
response.writeHead(500);
response.end("I'm not well. Please restart me!");
return;
}
response.writeHead(200);
response.end("You've hit " + os.hostname() + "\n");
};

let www = http.createServer(handler);
www.listen(8080);
20 changes: 20 additions & 0 deletions kubia-unhealthy/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "kubernetes-basiclearning",
"version": "1.0.0",
"description": "Understand kubernetes step by step.",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/knrt10/kubernetes-basicLearning.git"
},
"author": "knrt10",
"license": "MIT",
"bugs": {
"url": "https://github.com/knrt10/kubernetes-basicLearning/issues"
},
"homepage": "https://github.com/knrt10/kubernetes-basicLearning#readme"
}
Loading

0 comments on commit 04d581d

Please sign in to comment.