Skip to content

Commit

Permalink
Update liveness/readiness probe with an endpoint without auth. (#543)
Browse files Browse the repository at this point in the history
  • Loading branch information
cfchase authored Sep 12, 2022
1 parent 7aef2ba commit 8aeb97d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
13 changes: 13 additions & 0 deletions backend/src/routes/api/health/healthUtils.ts
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' };
}
};
9 changes: 9 additions & 0 deletions backend/src/routes/api/health/index.ts
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);
});
};
6 changes: 2 additions & 4 deletions manifests/base/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,16 @@ spec:
cpu: 1000m
memory: 2Gi
livenessProbe:
httpGet:
path: /api/config
tcpSocket:
port: 8080
scheme: HTTP
initialDelaySeconds: 30
timeoutSeconds: 15
periodSeconds: 30
successThreshold: 1
failureThreshold: 3
readinessProbe:
httpGet:
path: /api/config
path: /api/health
port: 8080
scheme: HTTP
initialDelaySeconds: 30
Expand Down

0 comments on commit 8aeb97d

Please sign in to comment.