Skip to content

Commit 78cd88b

Browse files
committed
Merged PR 878: add package readiness/liveness probe
- add /healthz endpoint for readiness and liveness - add liveness/readiness probe cfg solved: #133005
1 parent c7881c4 commit 78cd88b

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

charts/package/templates/package-deploy.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,38 @@ spec:
4141
- name: &package-container_name fabrikam-package
4242
image: {{ .Values.dockerregistry }}{{ .Values.dockerregistrynamespace }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}
4343
imagePullPolicy: {{ .Values.image.pullPolicy }}
44+
readinessProbe:
45+
httpGet:
46+
path: {{ required "readinessProbe.httpGet.path is required" .Values.readinessProbe.httpGet.path }}
47+
port: {{ required "readinessProbe.httpGet.port is required" .Values.readinessProbe.httpGet.port }}
48+
{{- if .Values.readinessProbe.initialDelaySeconds }}
49+
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
50+
{{- end }}
51+
{{- if .Values.readinessProbe.periodSeconds }}
52+
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
53+
{{- end }}
54+
{{- if .Values.readinessProbe.timeoutSeconds }}
55+
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
56+
{{- end }}
57+
{{- if .Values.readinessProbe.failureThreshold }}
58+
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
59+
{{- end }}
60+
livenessProbe:
61+
httpGet:
62+
path: {{ required "livenessProbe.httpGet.path is required" .Values.livenessProbe.httpGet.path }}
63+
port: {{ required "livenessProbe.httpGet.port is required" .Values.livenessProbe.httpGet.port }}
64+
{{- if .Values.livenessProbe.initialDelaySeconds }}
65+
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
66+
{{- end }}
67+
{{- if .Values.livenessProbe.periodSeconds }}
68+
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
69+
{{- end }}
70+
{{- if .Values.livenessProbe.timeoutSeconds }}
71+
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
72+
{{- end }}
73+
{{- if .Values.livenessProbe.failureThreshold }}
74+
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
75+
{{- end }}
4476
resources:
4577
requests:
4678
cpu: {{ required "A valid .Values.resources.requests.cpu entry required!" .Values.resources.requests.cpu }}

charts/package/values.yaml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ image:
88
tag:
99
pullPolicy: IfNotPresent
1010
reason: unknown
11+
readinessProbe:
12+
httpGet:
13+
path: /healthz
14+
port: 80
15+
initialDelaySeconds: 40
16+
periodSeconds: 15
17+
timeoutSeconds: 2
18+
failureThreshold: 5
19+
livenessProbe:
20+
httpGet:
21+
path: /healthz
22+
port: 80
23+
initialDelaySeconds: 50
24+
periodSeconds: 15
1125
log:
1226
level: error
1327
cosmosDb:
@@ -17,4 +31,4 @@ tags:
1731
prod: false
1832
qa: false
1933
staging: false
20-
current: false
34+
current: false

src/shipping/package/app/server.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Licensed under the MIT License (MIT). See License.txt in the repo root for license information.
44
// ------------------------------------------------------------
55

6+
const _ = require('koa-route');
67
import * as Koa from 'koa';
78
import * as bodyParser from "koa-bodyparser";
89

@@ -40,6 +41,15 @@ export class PackageService {
4041
// Configure logging
4142
app.use(logger(Settings.logLevel()));
4243

44+
// Add simple health check endpoint
45+
app.use(_.get('/healthz', (ctx) => {
46+
var logger : ILogger = ctx.state.logger;
47+
logger.info('Readiness/Liveness Probe Status: %s', "OK");
48+
49+
ctx.status = 200;
50+
ctx.body = {status: 'OK'};
51+
}));
52+
4353
// Configure global exception handling
4454
// Use: ctx.throw('Error Message', 500);
4555
// in the controller methods to set the status code and exception message

0 commit comments

Comments
 (0)