3

I have a web app on OpenShift v3 (all-in-One), using the Wildfly Builder Image. In addition, I created a service named xyz, to point to an external host+IP. Something like this:

        "kind": "Service",
        "apiVersion": "v1",
        "metadata": { "name": "xyz" },
        "spec": {
            "ports": [
                {   "port": 61616,
                    "protocol": "TCP",
                    "targetPort": 61616
                }
            ],
            "selector": {}
        }

I also have an endpoint, pointing externally, but that is not relevant for this question.

When deployed, my program can access an environment variable named XYZ_PORT=tcp://172.30.192.186:61616

However, I cannot figure out how to see all the values of all such variables either via the web-console, or using the CLI. Using the web-console, I cannot see it being injected into the YAML.

I tried some of the oc env options, but none seem to list what I want.

Darius X.
  • 2,886
  • 4
  • 24
  • 51

1 Answers1

2

Let's say you are deploying kitchensink, then the below CLI should list all the environment variables:

oc env bc/kitchensink --list
user1063287
  • 10,265
  • 25
  • 122
  • 218
Anil
  • 56
  • 5
  • 4
    You possibly meant ``oc set env dc/kitchensink --list``. Doing it on ``bc`` shows build time environment variables. This also will not show all the environment variables set automatically by Docker, which is what environment variable in question which is referenced looks to be. Would need to run ``env`` in the running pod as something like ``oc exec pod/kitchensink-a1b23 env`` to see all that were set in pod. – Graham Dumpleton Nov 10 '16 at 22:55
  • @GrahamDumpleton: Thank you. Can you please convert that to an answer, for posterity :). One thing though: I did not use the command exactly as specified. It said slashes were not allowed in the name. Instead, I used oc exec podname -c containername env – Darius X. Nov 11 '16 at 14:19
  • 2
    Correct, ``oc exec`` only takes a pod name, so ``pod/`` wasn't needed. Was typing it from memory. :-) – Graham Dumpleton Nov 11 '16 at 20:14
  • Why is `set` used instead of `get` for *viewing* variables? – user1063287 Nov 19 '18 at 14:34
  • 1
    For reference, following Graham's suggestion, I had to use this to view all envars for MongoDB: `oc exec mongodb-20-xxxx env` – user1063287 Nov 19 '18 at 14:36
  • Yeah, weird on the `set` part, but hey - it works. Thanks. – JGlass Jun 22 '21 at 19:04