liveBook · Manning

Namespace

As explained in Kubernetes for Developers

A Kubernetes namespace is a logical scope that groups and isolates named resources within a cluster.

A namespace is a logical scope inside a Kubernetes cluster. It lets separate environments or applications use the same resource names, such as foo-deployment and foo-service, without collisions. section 11.1

Namespaces make staging and production easier to keep similar. The same configuration can be applied to each namespace, while differences such as replica counts and external credentials remain environment-specific. section 11.0 section 11.1

Use namespaces to:

  • Separate production, staging, integration testing, developer, team, or application environments. section 11.1.1 section 11.5
  • Run kubectl commands against the currently selected namespace, reducing accidental changes elsewhere. section 11.1
  • Reuse declarative configuration across namespaces instead of renaming every Deployment and Service. section 11.1.1 section 11.1.2

Staging namespace

Create a staging namespace, switch the current kubectl context to it, and apply the configuration with kubectl apply -f .. The same resource names can then exist in production without collision. For safer rollouts, verify that the selected namespace matches the configuration directory before applying changes. section 11.1 section 11.1.1 section 11.3

Figure 11.1 A Kubernetes cluster with two namespaces. Note that the Deployment and Service objects in these namespaces have the same name in both.
11-01

Compare two namespaces that contain Deployment and Service objects with identical names. section 11.1

How Kubernetes for Developers covers it

How deep it goes
Explains naming, context selection, reuse, and rollout safeguards, but does not detail namespace internals.
Examples
Uses production and staging namespaces, repeated resource names, kubectl commands, reusable YAML, and namespace-checking rollout scripts.
What it assumes
Assumes basic kubectl and Kubernetes configuration files while teaching namespace creation, selection, and reuse.
What you can do after
Operate/configure environments by selecting namespaces, reusing manifests, and validating rollout targets before applying changes.
How it connects
Connects namespaces with Kubernetes clusters, Deployments, Services, kubectl contexts, configuration as code, GitOps, and RBAC.

Also explained in

Compare how 20 books explain namespace →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kubernetes for Developers. The section links point to the parts of the book it draws on.