k8s学习(8):pod-start、stop

start

Pod.spec.containers.lifecycle.postStart

stop

Pod.spec.containers.lifecycle.preStop

例子

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
apiVersion: v1
kind: Pod
metadata:
name: lifecycle-pod
spec:
containers:
- name: lifecycle-container
image: hub.test.com/library/myapp:v1
imagePullPolicy: IfNotPresent
lifecycle:
postStart:
exec:
command: ['sh', '-c', 'echo postStart > /usr/share/message']
preStop:
exec:
command: ['sh', '-c', 'echo preStop > /usr/share/message']

pod phase 可能存在的值

image-20200130235102503