关于Liveness 探测和 Readiness 探测在使用中

2020-07-22  本文已影响0人  生活就是闹剧
实验目的
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
实验小结

副本数变化没有任何变化,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
实验小结

副本数变化没有任何变化,健康状态下ep可以挂载Pod IP
健康健康,不健康从ep摘除,健康从ep挂载


整体总结
上一篇下一篇

猜你喜欢

热点阅读