Skip to main content

More Info:

Placing resources in the default namespace prevents proper segregation and access control. Use purpose-specific namespaces instead.

Risk Level

Low

Address

Security

Compliance Standards

  • CIS Kubernetes

Triage and Remediation

Remediation

Manual Steps

  1. List all workloads and core resources in the default namespace
    • Run on: any machine with kubectl access
    Review whether each object is intentionally in default or just there by habit/convenience.
  2. Identify ownership and required segregation for each object
    • Run on: any machine with kubectl access
    For each application or component, decide:
    • Which team/tenant owns it.
    • What security or lifecycle boundaries it needs.
    • What namespace(s) should exist instead (e.g., team-a-prod, shared-infra, monitoring).
  3. Create or confirm purpose-specific namespaces
    • Run on: any machine with kubectl access
      For each logical grouping you identified:
    (Adjust names as decided; skip if already present: kubectl get ns to check.)
    Optionally add labels/annotations to express purpose/ownership:
  4. Plan and migrate resources out of default to their target namespaces
    • Run on: any machine with kubectl access
      For each object to move:
    1. Export its manifest:
    2. Edit the file:
      • Change metadata.namespace: default to the target namespace.
      • Update references (serviceAccountName, ConfigMap/Secret names, RoleBindings, NetworkPolicies) if they change.
    3. Apply to the new namespace and delete from default:
    Repeat this pattern for Services, ConfigMaps, Secrets, ServiceAccounts, Roles/RoleBindings, NetworkPolicies, Jobs/CronJobs, PVCs (being careful with data and StorageClass constraints).
  5. Harden RBAC and defaults to discourage future use of default
    • Run on: any machine with kubectl access
      Consider:
    • Removing broad bindings in default:
    • Creating least-privilege RoleBindings only in intended namespaces and ensuring users’ kubeconfigs specify a non-default namespace:
  6. Verify that default is no longer used for application resources
    • Run on: any machine with kubectl access
    Confirm that:
    • Only objects you explicitly want there remain (often just system bootstrap artifacts, if any).
    • All application, team, or environment-specific resources have been moved to purpose-specific namespaces.

Using kubectl

Run these commands from any machine with kubectl access.

1. List all namespaces and spot obvious mis-use of default

What to look for (potential problems):
  • Only default, kube-system, and other system namespaces exist, and no clearly purpose-specific namespaces for apps or teams.
  • Application names suggest they should have their own namespaces, but do not (e.g., you see payments, frontend as Deployments in default later).

2. See what is currently running in the default namespace

If you also use other workload types:
What to look for (potential problems):
  • Business applications (e.g., orders-api, payments-db, frontend) running in default.
  • Shared infrastructure components (e.g., logging, monitoring, CI/CD agents) running in default.
  • Any long-lived workloads or services that clearly belong to a specific team, environment (dev/test/prod), or function, but are not in a dedicated namespace.
Using default for:
  • Only temporary/manual testing objects, clearly named as such and cleaned up regularly, is usually acceptable.
  • Anything production-like is a concern.

3. Check RBAC bindings that reference the default namespace

What to look for (potential problems):
  • Broad roles (e.g., with * verbs or many resources) attached in default, especially if:
    • default contains many or critical workloads.
    • ServiceAccounts in default are used by multiple apps/teams.
This indicates access control is being applied to a “catch-all” namespace instead of segregated namespaces.

4. Check what is using the default ServiceAccount

What to look for (potential problems):
  • Many or critical pods using the implicit default ServiceAccount (<none> or default in the output), especially if:
    • Those pods belong to distinct applications that should have isolated privileges.
    • There are no app-specific ServiceAccounts/roles/namespaces.
This suggests both namespace and identity segregation are not being used.

5. Review cluster-wide workloads that omit a namespace (using default implicitly)

To spot resources that may be created without specifying -n or metadata.namespace:
What to look for (potential problems):
  • Any production or shared system component appearing in default.
  • Patterns showing that most application resources land in default instead of in dedicated namespaces.

Use these observations to decide:
  • Which applications or components currently in default should be moved into dedicated namespaces.
  • What namespace structure (per app, per team, per environment) best supports your access control and segregation requirements.