How to get cluster subdomain in kubernetes deployment config template

1/22/2018

On kubernetes 1.6.1 (Openshift 3.6 CP) I'm trying to get the subdomain of my cluster using $(OPENSHIFT_MASTER_DEFAULT_SUBDOMAIN) but it's not dereferencing at runtime. Not sure what I'm doing wrong, docs show this is how environment parameters should be acquired. https://v1-6.docs.kubernetes.io/docs/api-reference/v1.6/#container-v1-core

- apiVersion: v1
  kind: DeploymentConfig
  spec:
    template:
      metadata:
        labels:
          deploymentconfig: ${APP_NAME}
          name: ${APP_NAME}
      spec:
        containers:
        - name: myapp
          env:
          - name: CLOUD_CLUSTER_SUBDOMAIN
            value: $(OPENSHIFT_MASTER_DEFAULT_SUBDOMAIN)
-- raffian
kubernetes
openshift
templates

1 Answer

1/23/2018

You'll need to set that value as an environment variable, this is the usage:

oc set env <object-selection> KEY_1=VAL_1

for example if your pod is named foo and your subdomain is foo.bar, you would use this command:

oc set env dc/foo OPENSHIFT_MASTER_DEFAULT_SUBDOMAIN=foo.bar

-- Tony
Source: StackOverflow