pod-hook
weight: 18 title: Pod Hook date: “2022-05-21T00:00:00+08:00” type: book
Pod Hook(钩子)是由
- exec:执行一段命令
- HTTP:发送
HTTP 请求。
参考下面的配置:
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"]
如果
调试hook
describe
命令来获取,如果有错误将可以看到 FailedPostStartHook
或 FailedPreStopHook
这样的