Liveness probe with http post

12/16/2018

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?

-- Ahmet
docker
kubernetes

1 Answer

12/17/2018

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!

-- yomateo
Source: StackOverflow