Define Namespace Names
Learn how to define kubernetes namespaces in Humanitec.


Kubernetes namespaces are used to organize Kubernetes objects within a Kubernetes cluster. Namespaces provide a level of separation from a networking perspective and also a boundary for in-cluster RBAC. In Humanitec, an Application is a collection of Workloads which are all run in the same namespace. This means that every Environment that is created has its own Namespace.
In order to perform any deployment, Humanitec requires a namespace name. By default, Humanitec will generate a namespace in the form of a UUID. This ensures that the namespace will be unique within the cluster.
In many cases, it would be better to have a more meaningful namespace name. THis can be done by matching a resource of type k8s-namespace to particular Environment in an Application.

Static namespaces per environment

In this case, we want to specify the namespace for a particular environment exactly. This is often the case for long lived environments such as Production or Staging.
To do this:
The namespace name must be unique to the environment within the cluster. Trying to deploy 2 different environments into the same cluster with the same namespace name will result in conflicts.

Dynamic namespaces

It is often the case that it would be useful to name the namespace based on the app and environment being deployed. This is especially useful for ephemeral environments.
The steps are the same as for static, except that the context placeholder is used.


To create a namespace that has the form {environment ID}-env-{application ID}-app, the following could be used:
The matching criteria can then be very broad - even for all namespaces. Care should be taken to ensure the namespace name will resolve to a unique name (like the one above).