關(guān)于Liveness 探測和 Readiness 探測在使用中 副本數(shù)變化-實驗

實驗目的
  • 判斷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 探測 用于自身是否可以正常接收流量,和非本身問題導致的錯誤,等待后端問題解決就可以恢復
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

友情鏈接更多精彩內(nèi)容