kubernetes,

Get current Kubernetes namespace

Jun 10, 2023 · 1 min read · Post a comment

We don’t want to be deploying in another (production most likely) namespace right. So, double check which namespace you are currently using with one of the commands below.

Prerequisites

  • Up and running k8s cluster
  • kubectl

Solution

Multiple ways to do so including:

  • kubectl config get-contexts
  • kubectl config view --minify --output 'jsonpath={..namespace}'

Conclusion

In case you face any issues, feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.