first commit
This commit is contained in:
commit
ba848e218d
1001 changed files with 152333 additions and 0 deletions
56
CloudNative/Kubernetes/Base/PreStop和PostStart.md
Normal file
56
CloudNative/Kubernetes/Base/PreStop和PostStart.md
Normal file
|
@ -0,0 +1,56 @@
|
|||
#### 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
|
||||
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue