3

I am trying to use below command to curl to the pod itself using podip as currently I don't want kubelet to request my pod for health check.

livenessProbe:
  exec:
    command:
    - curl
    - $POD_IP:9990/admin/ping
  initialDelaySeconds: 3
  periodSeconds: 5

but the env variable $POD_IP is not recognized here,

Could not resolve host: $POD_IP

How to configure this so that env var can be read by curl in the command.

reference: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.9/#execaction-v1-core

zillani
  • 1,070
  • 3
  • 18
  • 26

2 Answers2

5

try following :

command:
- bash
- -c
- curl $POD_IP:9990/admin/ping
Radek 'Goblin' Pieczonka
  • 21,554
  • 7
  • 52
  • 48
  • More info about how to perform commands here: https://stackoverflow.com/questions/33887194/how-to-set-multiple-commands-in-one-yaml-file-with-kubernetes – debiasej Dec 17 '19 at 10:04
0

Try using escaping $ with \$ this has worked for me.

livenessProbe:
exec:
command:
- curl
- \$POD_IP:9990/admin/ping
initialDelaySeconds: 3
periodSeconds: 5