Openshift: Where's KUBERNETES_NAMESPACE on pod/container

6/27/2018

I need to get access to current namespace. I've look up KUBERNETES_NAMESPACE and OPENSHIFT_NAMESPACE but they are unset.

$ oc rsh wsec-15-t6xj4
 $ env | grep KUBERNETES
KUBERNETES_SERVICE_PORT=443
KUBERNETES_PORT=tcp://172.30.0.1:443
KUBERNETES_PORT_53_TCP_ADDR=172.30.0.1
KUBERNETES_PORT_53_UDP_ADDR=172.30.0.1
KUBERNETES_PORT_53_TCP_PORT=53
KUBERNETES_PORT_53_TCP_PROTO=tcp
KUBERNETES_PORT_53_UDP_PORT=53
KUBERNETES_SERVICE_PORT_DNS=53
KUBERNETES_PORT_53_UDP_PROTO=udp
KUBERNETES_PORT_443_TCP_ADDR=172.30.0.1
KUBERNETES_PORT_53_TCP=tcp://172.30.0.1:53
KUBERNETES_PORT_53_UDP=udp://172.30.0.1:53
KUBERNETES_PORT_443_TCP_PORT=443
KUBERNETES_PORT_443_TCP_PROTO=tcp
KUBERNETES_SERVICE_PORT_DNS_TCP=53
KUBERNETES_PORT_443_TCP=tcp://172.30.0.1:443
KUBERNETES_SERVICE_PORT_HTTPS=443
KUBERNETES_SERVICE_HOST=172.30.0.1

Also the content of /var/run/secrets/kubernetes.io/namespace is empty.

Any ideas?

-- Jordi
kubernetes
openshift

1 Answer

6/27/2018

OpenShift are using Project instead Namespace.

https://docs.openshift.com/container-platform/3.9/architecture/core_concepts/projects_and_users.html#namespaces

It extended features of kubernetes namespace, such as resource limitation, rbac and so on.

-- Daein Park
Source: StackOverflow