Skip to content

Commit 204e393

Browse files
committed
Add hub.lifecycle configuration
1 parent c1e9400 commit 204e393

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

jupyterhub/schema.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,19 @@ properties:
10921092
description: |
10931093
A k8s native specification of resources, see [the
10941094
documentation](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#resourcerequirements-v1-core).
1095+
lifecycle: &lifecycle-spec
1096+
type: object
1097+
additionalProperties: false
1098+
description: |
1099+
A k8s native specification of lifecycle hooks on the container, see [the
1100+
documentation](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#lifecycle-v1-core).
1101+
properties:
1102+
postStart:
1103+
type: object
1104+
additionalProperties: true
1105+
preStop:
1106+
type: object
1107+
additionalProperties: true
10951108
services:
10961109
type: object
10971110
additionalProperties: true

jupyterhub/templates/hub/deployment.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ spec:
179179
securityContext:
180180
{{- $securityContext | toYaml | trimSuffix "\n" | nindent 12 }}
181181
{{- end }}
182+
{{- with .Values.hub.lifecycle }}
183+
lifecycle:
184+
{{- . | toYaml | trimSuffix "\n" | nindent 12 }}
185+
{{- end }}
182186
env:
183187
- name: PYTHONUNBUFFERED
184188
value: "1"

jupyterhub/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ hub:
8888
runAsUser: 1000
8989
runAsGroup: 1000
9090
allowPrivilegeEscalation: false
91+
lifecycle: {}
9192
services: {}
9293
pdb:
9394
enabled: false

tools/templates/lint-and-validate-values.yaml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,19 @@ hub:
124124
requests:
125125
cpu: 100m
126126
memory: 512Mi
127+
lifecycle: &lifecycle
128+
postStart:
129+
exec:
130+
command:
131+
- "/bin/sh"
132+
- "-c"
133+
- "echo Hello from the postStart handler >> /usr/share/message"
134+
preStop:
135+
exec:
136+
command:
137+
- "/bin/sh"
138+
- "-c"
139+
- "echo Hello from the preStart handler >> /usr/share/message"
127140
services:
128141
tests:
129142
apiToken: mocked-api-token
@@ -336,7 +349,7 @@ singleuser:
336349
events: true
337350
extraLabels: {}
338351
extraEnv: {}
339-
lifecycleHooks: {}
352+
lifecycleHooks: *lifecycle
340353
initContainers:
341354
- name: mock-init-container-name
342355
image: mock-init-container-image

0 commit comments

Comments
 (0)