Usage of Namespaces in Kubernetes

8/9/2021

I got a question regarding namespaces and seeking your expertise to clear out my doubts. What I understood about namespaces is that they are there to introduce logical boundaries among teams and projects. Of course, I read somewhere namespaces can be used to introduce/define different environments within the same cluster. E.g Test, UAT and PRODUCTION.

However, if an organization is developing a solution and that solution consists of X number of microservices and have dedicated teams to look after those services, should we still need to use namespaces to separate them or are they gonna deploy in one single namespace reflecting the solution?

E.g if we are developing an e-commerce application: Inventory, ShoppingCart, Payment, Orders etc. would be the microservices that I can think of. Should we deploy them under the namespace of sky-commerce for an instance? or should they need dedicated namespaces.?

My other question is. if we deploy services in different namespaces, is it possible for us to access them through APIGateway/ Ingress controller?

For an instance, I have the front-end SPA application and it has its BFF (Backend For Frontend). can the BFF access the other services through the APIGateway/Ingress controller?

Please help me to clear these doubts.

Thanks in advance for your prompt reply in this regard.

RSF

-- RSF
kubernetes
namespaces

2 Answers

8/10/2021

When creating a new Kubernetes namespace, a request is sent using the namespace API using the defined syscalls, and since Kubernetes has admin privileges, a new namespace will be created. The new namespace will contain specifications for the capabilities of a new process assigned under its domain.

In regards to your question above, yes you can keep services in different namespaces as long as they are able to talk together and render the services to the outside world as one piece.

Since all organizations are different, it is up to you to figure out how best to implement and manage Kubernetes Namespaces. In general, aim to:

  • Create an effective Kubernetes Namespace structure

  • Keep namespaces simple and application-specific

  • Label everything

  • Use cluster separation when necessary

-- Chandra Sekar
Source: StackOverflow

8/10/2021

Namespaces are cheap, use lots of them. Only ever put two things in the same namespace if they are 100% a single unit (two daemons that are always updated at the same time and are functionally a single deployment) or if you must because a related object is used (such as a Service being in the same ns as Pods it references).

-- coderanger
Source: StackOverflow