Docs/CloudNative/Kubernetes/Base/PreStop和PostStart.md
2022-10-18 16:59:37 +08:00

56 lines
No EOL
870 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#### preStoppod停止前操作优雅停止服务
```
apiVersion: v1
kind: Pod
metadata:
name: PreStop-demo-v1
namespace: demo-ns
labels:
app: prestop
version: v1
spec:
containers:
- name: prestop-demo
image: busybox
ports:
- name: pre-port
containerPort: 80
protocol: TCP
lifecycle:
preStop:
exec: ## httpGet 或 tcpSocket
command:
- '/bin/sh'
- '-c'
- 'echo stop'
```
#### postStart,pod启动前操作
```
apiVersion: v1
kind: Pod
metadata:
name: PostStart-demo-v1
namespace: demo-ns
labels:
app: poststart
version: v1
spec:
containers:
- name: poststart-demo
image: busybox
ports:
- name: post-port
containerPort: 80
protocol: TCP
lifecycle:
postStart:
tcpSocket:
port: 80
```