kubernetes: Cannot access fieldRef for `spec.nodeName` or `status.podIP` through downwardAPI volume interface
Is this a BUG REPORT or FEATURE REQUEST?:
/kind bug
What happened:
Applying this Pod configuration:
apiVersion: v1
kind: Pod
metadata:
name: dapi-files
spec:
containers:
- name: dapi-files
image: superorbital/toolbox:latest
command: ["sh", "-c"]
args:
- while true; do grep -H "" /etc/podinfo/*; sleep 5; done;
volumeMounts:
- name: podinfo
mountPath: /etc/podinfo
readOnly: true
volumes:
- name: podinfo
downwardAPI:
items:
- path: "nodename"
fieldRef:
fieldPath: spec.nodeName
- path: "address"
fieldRef:
fieldPath: status.podIP
Resulted in this error:
$ kubectl apply -f dapi-files.yaml
The Pod "dapi-files" is invalid:
* spec.volumes[0].downwardAPI.fieldRef.fieldPath: Unsupported value: "spec.nodeName": supported values: "metadata.annotations", "metadata.labels", "metadata.name", "metadata.namespace", "metadata.uid"
* spec.volumes[0].downwardAPI.fieldRef.fieldPath: Unsupported value: "status.podIP": supported values: "metadata.annotations", "metadata.labels", "metadata.name", "metadata.namespace", "metadata.uid"
* spec.containers[0].volumeMounts[0].name: Not found: "podinfo"
What you expected to happen:
I expected the Pod to run, with the nodename available in /etc/podinfo/nodename and the IP address available in /etc/podinfo/address.
How to reproduce it (as minimally and precisely as possible):
The above is about as minimal a reproduction as I can come up with.
Anything else we need to know?:
The documentation for the file based downwardAPI implies I should be able to access these values (emphasis added):
The following information is available to containers through environment variables and
downwardAPIvolumes:Information available via
fieldRef:
spec.nodeName- the node’s namestatus.hostIP- the node’s IPmetadata.name- the pod’s namemetadata.namespace- the pod’s namespacestatus.podIP- the pod’s IP addressspec.serviceAccountName- the pod’s service account namemetadata.uid- the pod’s UIDmetadata.labels['<KEY>']- the value of the pod’s label<KEY>(for example,metadata.labels['mylabel']); available in Kubernetes 1.9+metadata.annotations['<KEY>']- the value of the pod’s annotation<KEY>(for example,metadata.annotations['myannotation']); available in Kubernetes 1.9+
However, kubectl explain seems to agree that those fieldRefs aren’t allowed:
$ kubectl explain pod.spec.volumes.downwardAPI.items.fieldRef
RESOURCE: fieldRef <Object>
DESCRIPTION:
Required: Selects a field of the pod: only annotations, labels, name and
namespace are supported.
ObjectFieldSelector selects an APIVersioned field of an object.
FIELDS:
apiVersion <string>
Version of the schema the FieldPath is written in terms of, defaults to
"v1".
fieldPath <string> -required-
Path of the field to select in the specified API version.
Maybe this is a documentation issue?
Environment:
- Kubernetes version (use
kubectl version):Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.0", GitCommit:"925c127ec6b946659ad0fd596fa959be43f0cc05", GitTreeState:"clean", BuildDate:"2017-12-15T21:07:38Z", GoVersion:"go1.9.2", Compiler:"gc", Platform:"darwin/amd64"} Server Version: version.Info{Major:"1", Minor:"10+", GitVersion:"v1.10.2-gke.1", GitCommit:"75d2af854b1df023c7ce10a8795b85d3dd1f8d37", GitTreeState:"clean", BuildDate:"2018-05-10T17:23:18Z", GoVersion:"go1.9.3b4", Compiler:"gc", Platform:"linux/amd64"} - Cloud provider or hardware configuration: GKE running 1.10
- OS (e.g. from /etc/os-release): Container-Optimized OS
- Kernel (e.g.
uname -a):Linux gke-lab-default-pool-74632492-rnkr 4.4.111+ - Install tools:
- Others:
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 10
- Comments: 37 (11 by maintainers)
I can confirm that it is not yet possible to access the fields: - status.podIP - status.hostIP - spec.nodeName
tested on AKS running 1.14.6
/remove-lifecycle stale
I still see this issue, with below mentioned version.