Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the current namespace in a Pod?

One way I could think of is to set an environment which value is the namespace of the Pod when defining the Pod.
Getting the namespace dynamically without requiring changes for Pod will be better because it lessens the burden of constructing a Pod.

So is there a way to get current namespace in a Pod?

like image 422
flyer Avatar asked Sep 05 '17 02:09

flyer


1 Answers

Try the file:

/var/run/secrets/kubernetes.io/serviceaccount/namespace
like image 61
Graham Dumpleton Avatar answered Sep 28 '22 10:09

Graham Dumpleton