-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlifecycle.yaml
62 lines (62 loc) · 1.91 KB
/
lifecycle.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: lifecycle
labels:
name: helloworld
spec:
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
template:
metadata:
labels:
app: lifecycle
spec:
initContainers: # here this container will run right in the beginning before the main container
# starts
- name: init
image: busybox
command: ['sh', '-c', 'sleep 10'] # here the command is only for sleeping for 10 seconds
containers:
- image: busybox
name: lifecyle-container
command: ['sh', '-c', 'echo $(date +%s): Running >> /timing && echo "The app is running!" && /bin/sleep 120'] # all the commands being executed are essentially for the purpose of observing
# the pod lifecycle
resources:
requests:
cpu: "20m"
memory: "55M"
livenessProbe:
exec:
command: ['sh', '-c', 'echo $(date +%s): livenessProbe >> /timing']
initialDelaySeconds: 35
timeoutSeconds: 30
readinessProbe:
exec:
command: ['sh', '-c', 'echo $(date +%s): readinessProbe >> /timing']
initialDelaySeconds: 35
timeoutSeconds: 10
lifecycle:
postStart:
exec:
command: ['sh', '-c', 'echo $(date +%s): postStart >> /timing && sleep 10 && echo $(date +%s): end postStart >> /timing']
preStop:
exec:
command: ['sh', '-c', 'echo $(date +%s): preStop >> /timing && sleep 10']
env:
- name: ENVVARNAME
value: ENVVARVALUE
ports:
- containerPort: 5000
name: my-name
volumeMounts:
- mountPath: /data
name: data
volumes:
- name: data
emptyDir: {}
restartPolicy: Always
imagePullPolicy: Always