is there something like httpPost in k8s

5/2/2019

I know that k8s have readynessProbe with httpGet method to check if service ready to work or not. Is there something like httpPost method to run POST request to /api/postService with some body and check return code? Or some tricky way to do it in yaml file.

-- Nikita Shesterikov
kubernetes
post

2 Answers

3/3/2020

I think this way is more reliable.

readinessProbe:
    exec:
      command:
      - sh
      - -c
      - >-
          curl -X POST http://localhost/api/postService -H 'Content-Type: application/json' -d '{\"test\": \"OK\"}'
-- alexdeia
Source: StackOverflow

5/2/2019

Can be done by running curl as an exec readinessProbe:

readinessProbe:
  exec:
    command:
    - "curl" 
    - "-X POST"
    - "-f"
    - "http://localhost/api/postService"

Of course you'd need to make sure to install curl in the Docker image that packages your service.

-- antweiss
Source: StackOverflow