apiVersion: v1
kind: Pod
metadata:
  name: envars-fieldref
  labels:
    purpose: demonstrate-envars
  namespace: fieldref-namespace
spec:
  containers:
  - name: fieldref-container
    image: nginx:latest
    command: [ "/bin/sh", "-c"]
    args:
      - while true; do
          echo -en '\n';
          printenv MY_NODE_NAME MY_POD_NAME MY_POD_NAMESPACE;
          printenv MY_POD_IP MY_POD_SERVICE_ACCOUNT;
          sleep 10;
        done;
    env:
       - name: NODE_NAME
         valueFrom:
           fieldRef:
             fieldPath: spec.nodeName
       - name: POD_NAME
         valueFrom:
           fieldRef:
             fieldPath: metadata.name
       - name: POD_NAMESPACE
         valueFrom:
           fieldRef:
             fieldPath: metadata.namespace
       - name: POD_IP
         valueFrom:
           fieldRef:
             fieldPath: status.podIP
       - name: POD_SERVICE_ACCOUNT
         valueFrom:
           fieldRef:
             fieldPath: spec.serviceAccountName
  restartPolicy: Never

