Skip to content

Commit

Permalink
feat(app): add startupProbe
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasduteil committed May 26, 2020
1 parent 375cb0d commit ec6e468
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 33 deletions.
Expand Up @@ -48,32 +48,39 @@ spec:
- image: >-
registry.gitlab.factory.social.gouv.fr/socialgouv/sample-next-app:123456789
livenessProbe:
failureThreshold: 11
failureThreshold: 6
httpGet:
path: /healthz
port: http
initialDelaySeconds: 5
initialDelaySeconds: 30
periodSeconds: 5
timeoutSeconds: 5
name: www
ports:
- containerPort: 8080
name: http
readinessProbe:
failureThreshold: 5
failureThreshold: 15
httpGet:
path: /healthz
port: http
initialDelaySeconds: 5
initialDelaySeconds: 0
periodSeconds: 5
timeoutSeconds: 5
successThreshold: 1
timeoutSeconds: 1
resources:
limits:
cpu: 500m
memory: 128Mi
requests:
cpu: 5m
memory: 16Mi
startupProbe:
failureThreshold: 12
httpGet:
path: /healthz
port: http
periodSeconds: 5
apiVersion: apps/v1
kind: Deployment
---
Expand Down
Expand Up @@ -48,32 +48,39 @@ spec:
- image: >-
registry.gitlab.factory.social.gouv.fr/socialgouv/sample-next-app:1.2.3
livenessProbe:
failureThreshold: 11
failureThreshold: 6
httpGet:
path: /healthz
port: http
initialDelaySeconds: 5
initialDelaySeconds: 30
periodSeconds: 5
timeoutSeconds: 5
name: www
ports:
- containerPort: 8080
name: http
readinessProbe:
failureThreshold: 5
failureThreshold: 15
httpGet:
path: /healthz
port: http
initialDelaySeconds: 5
initialDelaySeconds: 0
periodSeconds: 5
timeoutSeconds: 5
successThreshold: 1
timeoutSeconds: 1
resources:
limits:
cpu: 500m
memory: 128Mi
requests:
cpu: 5m
memory: 16Mi
startupProbe:
failureThreshold: 12
httpGet:
path: /healthz
port: http
periodSeconds: 5
apiVersion: apps/v1
kind: Deployment
---
Expand Down
Expand Up @@ -29,32 +29,39 @@ spec:
- image: >-
registry.gitlab.factory.social.gouv.fr/socialgouv/sample-next-app:1.2.3
livenessProbe:
failureThreshold: 11
failureThreshold: 6
httpGet:
path: /healthz
port: http
initialDelaySeconds: 5
initialDelaySeconds: 30
periodSeconds: 5
timeoutSeconds: 5
name: www
ports:
- containerPort: 8080
name: http
readinessProbe:
failureThreshold: 5
failureThreshold: 15
httpGet:
path: /healthz
port: http
initialDelaySeconds: 5
initialDelaySeconds: 0
periodSeconds: 5
timeoutSeconds: 5
successThreshold: 1
timeoutSeconds: 1
resources:
limits:
cpu: 500m
memory: 128Mi
requests:
cpu: 5m
memory: 16Mi
startupProbe:
failureThreshold: 12
httpGet:
path: /healthz
port: http
periodSeconds: 5
apiVersion: apps/v1
kind: Deployment
---
Expand Down
38 changes: 28 additions & 10 deletions src/components/app/__snapshots__/index.test.ts.snap
Expand Up @@ -30,12 +30,12 @@ Object {
Object {
"image": "image_name:image_tag",
"livenessProbe": Object {
"failureThreshold": 11,
"failureThreshold": 6,
"httpGet": Object {
"path": "/healthz",
"port": "http",
},
"initialDelaySeconds": 5,
"initialDelaySeconds": 30,
"periodSeconds": 5,
"timeoutSeconds": 5,
},
Expand All @@ -47,14 +47,15 @@ Object {
},
],
"readinessProbe": Object {
"failureThreshold": 5,
"failureThreshold": 15,
"httpGet": Object {
"path": "/healthz",
"port": "http",
},
"initialDelaySeconds": 5,
"initialDelaySeconds": 0,
"periodSeconds": 5,
"timeoutSeconds": 5,
"successThreshold": 1,
"timeoutSeconds": 1,
},
"resources": Object {
"limits": Object {
Expand All @@ -66,6 +67,14 @@ Object {
"memory": "16Mi",
},
},
"startupProbe": Object {
"failureThreshold": 12,
"httpGet": Object {
"path": "/healthz",
"port": "http",
},
"periodSeconds": 5,
},
},
],
},
Expand Down Expand Up @@ -176,12 +185,12 @@ Object {
Object {
"image": "image_name:image_tag",
"livenessProbe": Object {
"failureThreshold": 11,
"failureThreshold": 6,
"httpGet": Object {
"path": "/healthz",
"port": "http",
},
"initialDelaySeconds": 5,
"initialDelaySeconds": 30,
"periodSeconds": 5,
"timeoutSeconds": 5,
},
Expand All @@ -193,14 +202,15 @@ Object {
},
],
"readinessProbe": Object {
"failureThreshold": 5,
"failureThreshold": 15,
"httpGet": Object {
"path": "/healthz",
"port": "http",
},
"initialDelaySeconds": 5,
"initialDelaySeconds": 0,
"periodSeconds": 5,
"timeoutSeconds": 5,
"successThreshold": 1,
"timeoutSeconds": 1,
},
"resources": Object {
"limits": Object {
Expand All @@ -212,6 +222,14 @@ Object {
"memory": "16Mi",
},
},
"startupProbe": Object {
"failureThreshold": 12,
"httpGet": Object {
"path": "/healthz",
"port": "http",
},
"periodSeconds": 5,
},
},
],
},
Expand Down
27 changes: 19 additions & 8 deletions src/components/app/deployment.ts
Expand Up @@ -22,14 +22,14 @@ export default (params: Params): Deployment => {
{
image: `${params.image.name}:${params.image.tag}`,
livenessProbe: {
// 11 x 5s + 30s = 30-1m
// 6 x 5s + 30s = 30-1m
// Kill the pod if not alive after 1 minute
failureThreshold: 11,
failureThreshold: 6,
httpGet: {
path: "/healthz",
port: "http",
},
initialDelaySeconds: 5,
initialDelaySeconds: 30,
periodSeconds: 5,
timeoutSeconds: 5,
},
Expand All @@ -41,16 +41,17 @@ export default (params: Params): Deployment => {
},
],
readinessProbe: {
// 5 x 5s + 5s = 5-30s
// Mark pod as unhealthy after 30s
failureThreshold: 5,
// 15 x 1s = 0-15s
// Mark pod as unhealthy after 15s
failureThreshold: 15,
httpGet: {
path: "/healthz",
port: "http",
},
initialDelaySeconds: 5,
initialDelaySeconds: 0,
periodSeconds: 5,
timeoutSeconds: 5,
successThreshold: 1,
timeoutSeconds: 1,
},
resources: {
limits: {
Expand All @@ -64,6 +65,16 @@ export default (params: Params): Deployment => {
...(params.requests ?? {}),
},
},
startupProbe: {
// 12 x 5s = 0-1min
// Takes up to 1 minute to start up before it fails
failureThreshold: 12,
httpGet: {
path: "/healthz",
port: "http",
},
periodSeconds: 5,
},
},
],
},
Expand Down

0 comments on commit ec6e468

Please sign in to comment.