Cameron Manavian
1 min readDec 2, 2020

--

There are two options at least:

A) If exposed as HTTP, the simplest way is to create an endpoint on your container like:

GET /ping

or

GET /health

You could also use the index route:

GET /

In the Kubernetes config:

readinessProbe:
failureThreshold: 3
httpGet:
path: /ping {YOUR PATH HERE}
port: 8080 {YOUR PORT HERE}
scheme: HTTP
initialDelaySeconds: 5
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1

And have it return a 200 status.

Without knowing your language of choice, here is one in Node.js with Express:

var express = require('express');
var router = express.Router();
router.get('/ping', (req, res) => {
res.json({
env: process.env.NODE_ENV
});
});

Here would be one using Rust and Actix:

async fn ping(_req: HttpRequest) -> impl Responder {
format!(
"I am healthy: {} v{}",
env!("CARGO_PKG_DESCRIPTION"),
env!("CARGO_PKG_VERSION")
)
}

B) If not using HTTP, then one way is to have your process write to a file every minute to confirm healthiness

Here is an example for the Kubernetes config:

readinessProbe:
exec:
command:
- test
- '`find .health_check -mmin -1`'
initialDelaySeconds: 5
periodSeconds: 15

I can expand on this more in another article if desired!

--

--

Cameron Manavian
Cameron Manavian

Written by Cameron Manavian

Father, Husband, Engineer, CTO, 15+ yrs of software engineering — cameronmanavian.com

No responses yet