56 lines
No EOL
870 B
Markdown
56 lines
No EOL
870 B
Markdown
#### preStop,pod停止前操作(优雅停止服务)
|
||
```
|
||
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
|
||
|
||
``` |