Can I use an HTTP POST in a preStop lifecycle hook in a Kubernetes job?

10/17/2018

I currently have the following lifecycle hook in my kubernetes config:

lifecycle:
      preStop:
        httpGet:
          path: /path
          port: 8080

I would like to call the shutdown endpoint of spring boot actuator in this hook, but this endpoint requires a post request instead of a get. Is this in any way possible or should I define my own endpoint that shuts down my app gracefully?

Thanks for your help!

-- Aletta
kubernetes
spring-boot
spring-boot-actuator

1 Answer

10/18/2018

You can add an exec lifecycle hook since httpPost is not a valid one, and assuming you have curl in your containers:

lifecycle:
  preStop:
    exec:
      command: ["curl", "-XPOST", "http://URL"]
-- Rico
Source: StackOverflow