實驗目的
- 判斷Liveness 探測 對副本數(shù)變化
- 判斷Readiness 探測 對副本數(shù)變化
- 判斷Readiness 探測 再次健康時是否從新加入svc
Liveness 實驗
# cat centos.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: centos-test
name: centos-test
spec:
replicas: 5
selector:
matchLabels:
app: centos-test
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: centos-test
spec:
containers:
- image: centos:7
name: centos
args:
- tail
- -f
- /etc/hosts
livenessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 60
periodSeconds: 3
# kubectl exec -it POD_NAME -- python -m SimpleHTTPServer 80
實驗小結(jié)
副本數(shù)變化沒有任何變化,pod名字也沒有變化.
Readiness 實驗
# cat centos.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: centos-test
name: centos-test
spec:
replicas: 5
selector:
matchLabels:
app: centos-test
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: centos-test
spec:
containers:
- image: centos:7
name: centos
args:
- tail
- -f
- /etc/hosts
readinessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 60
periodSeconds: 3
---
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
app: centos-test
name: centos-svc
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
app: centos-test
type: NodePort
# kubectl exec -it POD_NAME -- python -m SimpleHTTPServer 80
實驗小結(jié)
副本數(shù)變化沒有任何變化,健康狀態(tài)下ep可以掛載Pod IP
健康健康,不健康從ep摘除,健康從ep掛載
整體總結(jié)
- Liveness 探測 用于應用本身導致的錯誤重啟可以快速解決
- Readiness 探測 用于自身是否可以正常接收流量格仲,和非本身問題導致的錯誤押袍,等待后端問題解決就可以恢復