Skip to content

Commit 8aeb97d

Browse files
authored
Update liveness/readiness probe with an endpoint without auth. (#543)
1 parent 7aef2ba commit 8aeb97d

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { KubeFastifyInstance } from '../../../types';
2+
import { createCustomError } from '../../../utils/requestUtils';
3+
4+
export const health = async (fastify: KubeFastifyInstance): Promise<{ health: string }> => {
5+
const kubeContext = fastify.kube?.currentContext || '';
6+
if (!kubeContext && !kubeContext.trim()) {
7+
const error = createCustomError('failed to get kube status', 'Failed to get Kube context', 503);
8+
fastify.log.error(error, 'failed to get status');
9+
throw error;
10+
} else {
11+
return { health: 'ok' };
12+
}
13+
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify';
2+
import { health } from './healthUtils';
3+
4+
export default async (fastify: FastifyInstance): Promise<void> => {
5+
// Unsecured route for health check
6+
fastify.get('/', async (request: FastifyRequest, reply: FastifyReply) => {
7+
return health(fastify);
8+
});
9+
};

manifests/base/deployment.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,16 @@ spec:
3939
cpu: 1000m
4040
memory: 2Gi
4141
livenessProbe:
42-
httpGet:
43-
path: /api/config
42+
tcpSocket:
4443
port: 8080
45-
scheme: HTTP
4644
initialDelaySeconds: 30
4745
timeoutSeconds: 15
4846
periodSeconds: 30
4947
successThreshold: 1
5048
failureThreshold: 3
5149
readinessProbe:
5250
httpGet:
53-
path: /api/config
51+
path: /api/health
5452
port: 8080
5553
scheme: HTTP
5654
initialDelaySeconds: 30

0 commit comments

Comments
 (0)