在 K8S 中,我们有活力和准备。两者都在完整的应用程序生命周期中运行。但这对我来说还不够。我想运行一些健康检查,但只在启动时运行,或者将准备就绪配置为仅在启动时运行。是否可以?
查看处理程序生命周期事件,根据您正在执行的运行状况检查探测的类型,处理程序事件会有所不同。我在一个简单的“hello-world”pod 上尝试了这个。在您的postStart
事件中设置一个命令,当容器构建并运行时,它只会运行一次。我的示例 yaml 文件如下所示:
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-world
labels:
app: hello-world
spec:
replicas: 1
selector:
matchLabels:
app: hello-world
template:
metadata:
labels:
app: hello-world
spec:
containers:
- image: paulbouwer/hello-kubernetes:1.5
lifecycle:
postStart:
exec:
command: ["/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"]
name: hello-world
ports:
- containerPort: 8080
name: http
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句