-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update liveness/readiness probe with an endpoint without auth. (#543)
- Loading branch information
Showing
3 changed files
with
24 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { KubeFastifyInstance } from '../../../types'; | ||
import { createCustomError } from '../../../utils/requestUtils'; | ||
|
||
export const health = async (fastify: KubeFastifyInstance): Promise<{ health: string }> => { | ||
const kubeContext = fastify.kube?.currentContext || ''; | ||
if (!kubeContext && !kubeContext.trim()) { | ||
const error = createCustomError('failed to get kube status', 'Failed to get Kube context', 503); | ||
fastify.log.error(error, 'failed to get status'); | ||
throw error; | ||
} else { | ||
return { health: 'ok' }; | ||
} | ||
}; |
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,9 @@ | ||
import { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify'; | ||
import { health } from './healthUtils'; | ||
|
||
export default async (fastify: FastifyInstance): Promise<void> => { | ||
// Unsecured route for health check | ||
fastify.get('/', async (request: FastifyRequest, reply: FastifyReply) => { | ||
return health(fastify); | ||
}); | ||
}; |
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