Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Liveness probe with http post

I'm running a web service that I can not change any of the specifications. I want to use liveness probe with HTTP POST on Kubernetes. I couldn't find anything available. All of my efforts with busybox and netcat have failed.

Is there a solution? Is it possible to build a custom liveness probe from any Linux dist?

like image 348
Ahmet Avatar asked Dec 16 '18 23:12

Ahmet


People also ask

What is difference between readiness and liveness probe?

Readiness probes are configured similarly to liveness probes. The only difference is that you use the readinessProbe field instead of the livenessProbe field. Configuration for HTTP and TCP readiness probes also remains identical to liveness probes.

Why did liveness probe fail in Kubernetes?

The liveness probe will be marked as failed when the container issues an unhealthy response. The probe is also considered failed if the service doesn't implement the gRPC health checking protocol. Monitor the health of your cluster and troubleshoot issues faster with pre-built dashboards that just work.

What happens if you don't specify a liveness probe?

What if I don't specify a liveness probe? If you don't specify a liveness probe, then OpenShift will decide whether to restart your container based on the status of the container's PID 1 process. The PID 1 process is the parent process of all other processes that run inside the container.

Does liveness probe restart pod or container?

The kubelet can optionally perform and react to three kinds of probes on running containers: livenessProbe. Indicates whether the container is running. If the liveness probe fails, the kubelet kills the container, and the container is subjected to its restart policy.


1 Answers

Kubernetes Probes only support HTTP GET, TCP & Command.

If you must check something over HTTP POST you could use a command approach and just curl -XPOST ..

An example would be:

...
      containers:
        - name:  k8-byexamples-spring-rest
          image: gcr.io/matthewdavis-byexamples/k8-byexamples-spring-rest:1d4c1401c9485ef61322d9f2bb33157951eb351f
          ports:
            - containerPort: 8080
              name: http
          livenessProbe:
            exec:
              command:
                - curl
                - -X POST
                - http://localhost/test123
            initialDelaySeconds: 5
            periodSeconds: 5
...

For more explanation see: https://matthewdavis.io/kubernetes-health-checks-demystified/.

Hope that helps!

like image 173
yomateo Avatar answered Sep 17 '22 07:09

yomateo