Search code examples
openshiftopenshift-originopenshift-client-toolsopenshift-enterprise

Openshift - Environment variable getting evaluated to hostname


I want to pass an environment variable that should get evaluated to the hostname of the running container. This is what I am trying to do

oc new-app -e DASHBOARD_PROTOCOL=http -e ADMIN_PASSWORD=abc@123 -e KEYCLOAK_URL=http://keycloak.openidp.svc:8080 -e KEYCLOAK_REALM=master -e DASHBOARD_HOSTNAME=$HOSTNAME -e GF_INSTALL_PLUGINS=grafana-simple-json-datasource,michaeldmoore-annunciator-panel,briangann-gauge-panel,savantly-heatmap-panel,briangann-datatable-panel grafana/grafana:5.2.1

How to ensure that the DASHBOARD_HOSTNAME gets evaluated to the value of the hostname of the running container image


Solution

  • For take the hostname value from a pod you could use the metadata.name. follow the eg:

      env:
        - name: HOSTNAME
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: metadata.name