Skip to content

Commit

Permalink
Merge pull request #1 from tombojer/master
Browse files Browse the repository at this point in the history
Add health endpoint
  • Loading branch information
niklasdoerfler committed Jun 23, 2023
2 parents 94823d3 + 1ef46f1 commit 8c0084d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
15 changes: 15 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ const dns = require('dns');
const app = express();
const port = 3000;


app.get('/health', (req, res, next) => {
const target = process.env.TARGET_HOSTS_DNS_NAME;
if (target == undefined) {
return next(new Error("environment variable TARGET_HOSTS_DNS_NAME is not set"))
}

dns.lookup(process.env.TARGET_HOSTS_DNS_NAME, { all: true }, (err, addresses) => {
if (addresses == undefined) {
return next(new Error("Unable to resolve hostname '" + process.env.TARGET_HOSTS_DNS_NAME + "'."));
}
res.send(addresses)
})
})

app.all('*', (req, res, next) => {
dns.lookup(process.env.TARGET_HOSTS_DNS_NAME, { all: true }, (err, addresses) => {
if (addresses == undefined) {
Expand Down
4 changes: 2 additions & 2 deletions helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ spec:
protocol: TCP
livenessProbe:
httpGet:
path: /
path: /health
port: http
readinessProbe:
httpGet:
path: /
path: /health
port: http

# environment configuration variables
Expand Down

0 comments on commit 8c0084d

Please sign in to comment.