OpenShift Downward API Operations: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
Line 7: Line 7:


=Expose OpenShift Information to Pod via Environment Variables=
=Expose OpenShift Information to Pod via Environment Variables=
Edit the deployment configuration for the pod we want to expose data to:
oc edit dc/<''dc-name''>
Add the following environment entires:
...
spec:
  ...
  template:
    ...
    spec:
      containers:
      - name: printenv
        <font color=teal>'''env''':</font>
          - <font color=teal>'''name: POD_NAME'''</font>
            <font color=teal>'''valueFrom:'''</font>
              <font color=teal>'''fieldRef:'''</font>
                <font color=teal>'''fieldPath: metadata.name'''</font>
          - <font color=teal>'''name: POD_NAMESPACE'''</font>
            <font color=teal>'''valueFrom:'''</font>
              <font color=teal>'''fieldRef:'''</font>
                <font color=teal>'''fieldPath: metadata.namespace'''</font>


=Expose OpenShift Information to Pod via Volumes =
=Expose OpenShift Information to Pod via Volumes =

Revision as of 04:22, 23 November 2017

Internal

Overview

Expose OpenShift Information to Pod via Environment Variables

Edit the deployment configuration for the pod we want to expose data to:

oc edit dc/<dc-name>

Add the following environment entires:

...
spec:
  ...
  template:
    ...
    spec:
      containers:
      - name: printenv
        env:
          - name: POD_NAME
            valueFrom:
              fieldRef:
                fieldPath: metadata.name
          - name: POD_NAMESPACE
            valueFrom:
              fieldRef:
                fieldPath: metadata.namespace

Expose OpenShift Information to Pod via Volumes