kubernetes: Downward API doesn't support status.podIPs to be used

Hi ,

I am trying to use downward API in daemonset spec to set IP and IP6 environment variables using the pod’s status.podIPs array.

  env:
    - name: IP
    valueFrom:
        fieldRef:
          fieldPath: status.podIPs[0].ip
    - name: IP6
    valueFrom:
        fieldRef:
          fieldPath: status.podIPs[1].ip	

But it throws error as shown below.

spec.template.spec.containers[0].env[7].valueFrom.fieldRef.fieldPath: Invalid value: “status.podIPs[0]”: error converting fieldPath: field label not supported: status.podIPs[0] spec.template.spec.containers[0].env[12].valueFrom.fieldRef.fieldPath: Invalid value: “status.podIPs[1]”: error converting fieldPath: field label not supported: status.podIPs[1] spec.template.spec.containers[0].env[7].valueFrom.fieldRef.fieldPath: Invalid value: “status.podIPs[0]”: error converting fieldPath: field label not supported: status.podIPs[0] spec.template.spec.containers[0].env[12].valueFrom.fieldRef.fieldPath: Invalid value: “status.podIPs[1]”: error converting fieldPath: field label not supported: status.podIPs[1]

Whether downward API could be enhanced to support accessing status.podIPs[0] or status.podIPs[1] ? With dual-stack feature implemented , this makes a case for accessing both values.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 20 (10 by maintainers)

Most upvoted comments

Is there a workaround or fix for this? It seems like we should be able to reference the array index of status.podIPs to use in environment variables.

What’s the problem with having all the IPs in a single environment variable and extracting them into individual values as needed in the container’s startup script?