Kubernetes Downward API Concepts: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
Line 7: Line 7:
=Overview=
=Overview=
Kubernetes is exposing pod information to the containers running inside the pod through files, which are projected in the container by a mechanism known as the Downward API.
Kubernetes is exposing pod information to the containers running inside the pod through files, which are projected in the container by a mechanism known as the Downward API.
=Example=
This is how the pod name and namespace can be projected to be available to containers running inside the pod.
Declare a "downwardAPI" volume and mount it in the pod:
<syntaxhighlight lang='yaml'>
apiVersion: v1
kind: Pod
metadata:
  name: loop
spec:
  containers:
  - name: loop
    image: docker.io/ovidiufeodorov/loop:latest
 
</syntaxhighlight>

Revision as of 23:25, 18 June 2020

External

Internal

Overview

Kubernetes is exposing pod information to the containers running inside the pod through files, which are projected in the container by a mechanism known as the Downward API.

Example

This is how the pod name and namespace can be projected to be available to containers running inside the pod.

Declare a "downwardAPI" volume and mount it in the pod:

apiVersion: v1
kind: Pod
metadata:
  name: loop
spec:
  containers:
  - name: loop
    image: docker.io/ovidiufeodorov/loop:latest