Skip to main content

More Info:

Placing resources in the default namespace makes it harder to apply access controls and segregation. Create dedicated namespaces and create all new resources within a specific namespace.

Risk Level

Low

Address

Security

Compliance Standards

  • CIS OKE

Triage and Remediation

Remediation

Manual Steps

  1. Identify all resources currently in the default namespace
    • Run on: any machine with kubectl access
    • Command:
    • Review which workloads, services, and other objects are using default and group them logically by application/team/environment.
  2. Decide target namespaces and create them if needed
    • For each logical group identified in step 1, decide a dedicated namespace name (e.g. team-a-prod, payments, logging).
    • Create missing namespaces:
  3. Plan RBAC and policy for the new namespaces
    • For each new namespace, define who should access it and at what level (view, edit, admin).
    • Example (adjust subjects and roles before applying):
    • Similarly review any NetworkPolicies, ResourceQuotas, PodSecurity policies/levels, etc., and prepare equivalents per namespace.
  4. Migrate workloads and supporting resources from default to the chosen namespaces
    • Export each object from default, edit metadata.namespace, and re-create it in the target namespace:
    • Repeat for Services, ConfigMaps, Secrets, Jobs/CronJobs, Ingresses, etc.
    • For workloads created by higher-level tools (Helm, GitOps, operators), update those tools’ configuration to deploy into the chosen namespaces instead of default.
  5. Prevent new workloads from accidentally landing in default
    • Update CI/CD, Helm values, Kustomize overlays, and any scripts to always set metadata.namespace explicitly or use --namespace in kubectl/Helm commands.
    • Optionally, restrict use of default via admission controls (e.g., ValidatingAdmissionPolicy, OPA/Gatekeeper) so that new Pods/Deployments/etc. in default are denied unless explicitly allowed.
  6. Verify that default is no longer in active use for application resources
    • Re-run the discovery and confirm only minimal/system objects (if any) remain:
    • Confirm your target namespaces now hold the expected resources:
    • Decide and document your policy on what (if anything) is allowed to remain in default and monitor periodically with the same commands.

Using kubectl

Run these commands from any machine with kubectl access.
  1. List resources currently in the default namespace
Problem indication: Any non-system workloads (apps, deployments, jobs, services, etc. that are part of normal application stacks) appearing here suggest the default namespace is being used inappropriately.
  1. Show all resource types in the default namespace, including non-pod objects
Problem indication: Application-related objects (ConfigMaps, Secrets, Ingresses, RBAC bindings, etc.) in default indicate mixed or unclear segregation of resources.
  1. Check which contexts default to the default namespace
Focus on the NAMESPACE column.Problem indication: Contexts with an empty NAMESPACE column default to default. If these contexts are used by humans or automation (CI/CD), they likely create resources in default unless explicitly overridden.
  1. Inspect RBAC bindings tied to the default namespace
Problem indication: Broad roles (e.g., edit, admin, or custom high-privilege roles) in the default namespace, or cluster role bindings referencing default service accounts, indicate that default may be carrying security-significant workloads or permissions.
  1. Identify service accounts actively used in the default namespace
Problem indication: Multiple custom service accounts or pods using them in default often mean real applications are deployed there instead of in dedicated namespaces.
  1. Verify whether key applications are running in non-default namespaces
If you know app labels (example: app=frontend), check where they run:
Problem indication: If important applications only appear in the default namespace, that application team has not been segregated into a dedicated namespace.These commands only surface the current state. Deciding which resources should move to dedicated namespaces and how to redesign access controls requires human review of:
  • Which objects are system/cluster-critical vs. app workloads.
  • Which teams/owners should have separate namespaces.
  • How RBAC and network policies will map to the new namespace structure.
Explanation of problematic output:
  • Any long-lived or production workload (Deployments, StatefulSets, DaemonSets, Jobs/CronJobs) listed under default indicates a problem; these should be moved to dedicated namespaces.
  • Services, Ingresses, ConfigMaps, Secrets, and NetworkPolicies in default tied to those workloads are also problematic and should be migrated with the workloads.
  • RoleBindings in default and ClusterRoleBindings whose subjects reference namespace: default may be overly broad; review whether access should instead be scoped to specific application namespaces.
  • Webhook, PSP, or other policy configurations that special-case namespace: default should be reviewed to ensure they are not encouraging or relying on use of the default namespace.