定义启动后和销毁前钩子示例:apiVersion: v1
kind: Pod
metadata:
name: lifecycle-demo
spec:
containers:
- name: lifecycle-demo-container
image: nginx
lifecycle:
postStart:
exec:
command: ["/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"]
preStop:
exec:
command: ["/usr/sbin/nginx","-s","quit"]
下面是一个在启动后执行多条指令的示例:apiVersion: v1
kind: Pod
metadata:
name: dyland-lua-api-pre
spec:
containers:
- name: dyland-lua-api-pre
image: hub.dz11.com/op-base/openresty:1.11.2.4
imagePullPolicy: Always
lifecycle:
postStart:
exec:
command:
- "sh"
- "-c"
- >
/bin/echo 'options single-request-reopen&