Skip to main content

More Info:

Namespaces provide administrative and security boundaries between groups of resources. Create namespaces for the objects in your deployment as needed.

Risk Level

Medium

Address

Security

Compliance Standards

  • CIS AKS

Triage and Remediation

Remediation

Manual Steps

  1. Inventory current namespaces and workloads
    • Run on: any machine with kubectl access
    • Commands:
    • Review which user workloads (apps) are running in default, kube-system, or other shared namespaces instead of dedicated ones.
  2. Map workloads to organizational or security boundaries
    • Decide how to group workloads into namespaces, for example by:
      • Environment: dev, test, staging, prod
      • Team/owner: payments, analytics, platform
      • Sensitivity: public, internal, restricted
    • Document for each application which namespace it should belong to and which other workloads it should be administratively separated from.
  3. Design the namespace layout and policies
    • For each planned namespace, decide:
      • Purpose and owner
      • Required access controls (RBAC) and network separation (if using NetworkPolicies)
      • Any resource quotas/limits that should apply
    • Optionally draft a namespace manifest template, for example:
  4. Create the required namespaces
    • Run on: any machine with kubectl access
    • For a simple namespace:
    • Or apply a manifest (repeat per namespace):
  5. Refactor workloads to use the new namespaces
    • Update manifests/Helm charts/IaC so each workload specifies the intended namespace and is no longer deployed into default or other shared namespaces. Examples:
      • With kubectl:
      • In a manifest, omit namespace under metadata and deploy with -n, or set an explicit metadata.namespace aligned to your design.
    • Carefully migrate existing workloads:
      • Export current manifest, adjust namespace, re-apply, then delete the old object:
    • Ensure dependent objects (Services, ConfigMaps, Secrets, RBAC bindings) are created in the same namespace and references are updated.
  6. Verify namespace-based separation is in place
    • Run on: any machine with kubectl access
    • Commands:
    • Confirm that:
      • User workloads are not running in default or kube-system.
      • Workloads are grouped into the intended namespaces that reflect your administrative and security boundaries.

Using kubectl

1. List all namespaces and basic metadata

Run on: any machine with kubectl access
Review:
  • Problem indicators:
    • Only default, kube-system, kube-public, kube-node-lease, and a small number of broad “catch‑all” namespaces like dev or prod, but many unrelated apps in each.
    • Business‑critical and non‑critical workloads mixed in the same namespace.
    • Security‑sensitive workloads (e.g., with elevated permissions) sharing a namespace with general apps.

2. See what runs in each namespace

Run on: any machine with kubectl accessAll workloads per namespace:
By specific namespace (example for default):
Review:
  • Problem indicators:
    • Many unrelated applications coexisting in a single namespace (e.g., multiple teams’ apps, shared test and production workloads).
    • System components or operators deployed in default instead of their own namespaces.
    • Lack of clear grouping (names don’t suggest ownership, environment, or function).

3. Identify applications still using the default namespace

Run on: any machine with kubectl access
Review:
  • Problem indicators:
    • Long list of application resources in default (not just small test/demo items).
    • Multi-team or multi-tenant workloads all deployed to default.

4. Inspect labels to infer ownership and boundaries

Run on: any machine with kubectl access
For a specific namespace:
Review:
  • Problem indicators:
    • Pods from different teams or applications (as indicated by labels like app, team, owner) mixed in the same namespace when they should be administratively separated.
    • Lack of consistent labeling, making it hard to reason about who owns what in each namespace.

5. Review namespace-level policies and their scope

Run on: any machine with kubectl accessNetworkPolicies:
ResourceQuotas and LimitRanges:
RBAC bindings by namespace:
Review:
  • Problem indicators:
    • Few namespaces with NetworkPolicies, ResourceQuotas, or RBAC bindings, implying broad, shared namespaces with weak administrative separation.
    • Single namespace where many different RoleBindings/roles are used to approximate per-team isolation instead of using separate namespaces.

6. Inspect specific namespaces in detail

Run on: any machine with kubectl access
Review:
  • Problem indicators:
    • Namespace description and contents show mixed environments (e.g., both dev and prod workloads).
    • Shared namespace used by multiple teams or tenants with no corresponding isolation mechanisms, suggesting missing administrative boundaries.
These commands surface how workloads are currently grouped and where namespaces are being used as broad buckets instead of clear administrative/security boundaries; a human must decide where new namespaces are needed and how to reorganize workloads.
How to interpret the output (what indicates a problem)Reviewers should look for:
  1. Workloads in shared / system namespaces
    • Output section 8: non‑platform application pods running in default, kube-system, or kube-public indicate missing administrative boundaries.
    • Expected: only core components and intentionally shared infra in these namespaces.
  2. Single namespace hosting unrelated applications
    • Output sections 1 and 3: many distinct applications or teams sharing the same namespace (especially default) suggests boundaries are not defined by function, environment, or owner.
  3. Lack of NetworkPolicies
    • Output section 7: namespaces listed as “without any NetworkPolicy” are likely on a flat network with no namespace‑level traffic controls, weakening isolation.
  4. ClusterRoles used inside many namespaces
    • Output sections 4 and 5: the same ClusterRole referenced in many RoleBindings across several namespaces can indicate that a nominal namespace boundary is bypassed by broad RBAC.
  5. System and user workloads mixed on the same nodes without taints/labels
    • Output section 9: no meaningful taints/labels separating system and user workloads can make it harder to enforce different policies per boundary.
  6. Catch‑all / ambiguous namespaces
    • Output sections 1–3: namespaces with vague names (e.g., misc, shared, tools) containing many different workloads usually indicate missing per‑team or per‑app namespaces.
Use these findings to decide where new namespaces (and corresponding RBAC and NetworkPolicies) should be introduced; any move/creation must be planned and applied manually with updated manifests and policies.