k8s: Unable to read environment variable in livenessProbes exec

3/2/2018

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
kubernetes

1 Answer

3/2/2018

try following :

command:
- bash
- -c
- curl $POD_IP:9990/admin/ping
-- Radek 'Goblin' Pieczonka
Source: StackOverflow