// Module included in the following assemblies:
//
// * nodes/nodes-containers-downward-api.adoc

:_mod-docs-content-type: PROCEDURE
[id="nodes-containers-downward-api-container-values-plugin_{context}"]
= Consuming container values using a volume plugin

[role="_abstract"]
Your containers can consume Downward API values by using a volume plugin.

Containers can consume the following values:

* Pod name

* Pod project/namespace

* Pod annotations

* Pod labels

The following procedure show how to use the volume plugin.

.Procedure

. Create a new pod spec that contains the environment variables you want the container to consume:

.. Create a `volume-pod.yaml` file similar to the following:
+
[source,yaml]
----
kind: Pod
apiVersion: v1
metadata:
  labels:
    zone: us-east-coast
    cluster: downward-api-test-cluster1
    rack: rack-123
  name: dapi-volume-test-pod
  annotations:
    annotation1: "345"
    annotation2: "456"
spec:
  securityContext:
    runAsNonRoot: true
    seccompProfile:
      type: RuntimeDefault
  containers:
    - name: volume-test-container
      image: gcr.io/google_containers/busybox
      command: ["sh", "-c", "cat /tmp/etc/pod_labels /tmp/etc/pod_annotations"]
      volumeMounts:
        - name: podinfo
          mountPath: /tmp/etc
          readOnly: false
      securityContext:
        allowPrivilegeEscalation: false
        capabilities:
          drop: [ALL]
  volumes:
  - name: podinfo
    downwardAPI:
      defaultMode: 420
      items:
      - fieldRef:
          fieldPath: metadata.name
        path: pod_name
      - fieldRef:
          fieldPath: metadata.namespace
        path: pod_namespace
      - fieldRef:
          fieldPath: metadata.labels
        path: pod_labels
      - fieldRef:
          fieldPath: metadata.annotations
        path: pod_annotations
  restartPolicy: Never
# ...
----

.. Create the pod from the `volume-pod.yaml` file by using the following command:
+
[source,terminal]
----
$ oc create -f volume-pod.yaml
----

.Verification

* Check the container logs and verify the presence of the configured fields by using the following command:
+
[source,terminal]
----
$ oc logs -p dapi-volume-test-pod
----
+
.Example output
[source,terminal]
----
cluster=downward-api-test-cluster1
rack=rack-123
zone=us-east-coast
annotation1=345
annotation2=456
kubernetes.io/config.source=api
----
