[Kubernetes] Pod Health

Kubernetes relies on Probes to determine the health of a Pod container. A Probe is a diagnostic performed periodically by the kubelet on a container.

docs

There are two types of Probes:

1. Livenss Probe

Liveness probes can be used to determine if a Pod is healthy and running as expected

2. Readiness Probe

Readiness probes can be used to determine if a Pod should receive requests

Failed Pod containers are recreated by default (restartPolicy defaults to Always).

What is the way to check Pod health?

ExecAction: Excutes an action inside the container

TSPSockerAction: TCP check against the container's IP address on specified port

HTTPGetAction: HTTP GET request against container

Probes can have the following results:

 - Success

 - Failure

 - Unknown

or

pods/probe/exec-liveness.yaml 

apiVersion: v1
kind: Pod
metadata:
  labels:
    test: liveness
  name: liveness-exec
spec:
  containers:
  - name: liveness
    image: k8s.gcr.io/busybox
    args:
    - /bin/sh
    - -c
    - touch /tmp/healthy; sleep 30; rm -rf /tmp/healthy; sleep 600
    livenessProbe:
      exec:
        command:
        - cat
        - /tmp/healthy
      initialDelaySeconds: 5
      periodSeconds: 5

--

猜你喜欢

转载自www.cnblogs.com/Answer1215/p/11774566.html