readinessProbe主要探測服務是否就緒,若是你的應用的readinessProbe運行失敗,那麼就會從組成service的端點中刪除,這樣就不會有流量經過Kubernetes服務發現機制來發送給它 shell
livenessProbe探測服務是否可,不可用時重啓podtcp
參數google
官方文檔: https://kubernetes.io/docs/ta...code
spec: containers: - name: liveness args: - /server image: gcr.io/google_containers/liveness readinessProbe: httpGet: path: /healthz port: 8080 httpHeaders: - name: X-Custom-Header value: Awesome initialDelaySeconds: 20 periodSeconds: 10 timeouteSeconds: 1 livenessProbe: httpGet: path: /healthz port: 8080 httpHeaders: - name: X-Custom-Header value: Awesome initialDelaySeconds: 20 periodSeconds: 10 timeouteSeconds: 1
spec: containers: - name: goproxy image: gcr.io/google_containers/goproxy:0.1 ports: - containerPort: 8080 readinessProbe: tcpSocket: port: 8080 initialDelaySeconds: 20 periodSeconds: 10 timeoutSeconds: 1 livenessProbe: tcpSocket: port: 8080 initialDelaySeconds: 20 periodSeconds: 10 timeoutSeconds: 1
spec: containers: - name: liveness args: - /bin/sh - -c - touch /tmp/healthy; sleep 30; rm -rf /tmp/healthy; sleep 600 image: gcr.io/google_containers/busybox livenessProbe: exec: command: - cat - /tmp/healthy initialDelaySeconds: 5 periodSeconds: 5