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
LowAddress
SecurityCompliance Standards
- CIS OKE
Triage and Remediation
- Remediation
Remediation
Manual Steps
Manual Steps
-
Identify all resources currently in the
defaultnamespace- Run on: any machine with kubectl access
- Command:
- Review which workloads, services, and other objects are using
defaultand group them logically by application/team/environment.
-
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:
- For each logical group identified in step 1, decide a dedicated namespace name (e.g.
-
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.
-
Migrate workloads and supporting resources from
defaultto the chosen namespaces- Export each object from
default, editmetadata.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.
- Export each object from
-
Prevent new workloads from accidentally landing in
default- Update CI/CD, Helm values, Kustomize overlays, and any scripts to always set
metadata.namespaceexplicitly or use--namespacein kubectl/Helm commands. - Optionally, restrict use of
defaultvia admission controls (e.g., ValidatingAdmissionPolicy, OPA/Gatekeeper) so that new Pods/Deployments/etc. indefaultare denied unless explicitly allowed.
- Update CI/CD, Helm values, Kustomize overlays, and any scripts to always set
-
Verify that
defaultis 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
defaultand monitor periodically with the same commands.
- Re-run the discovery and confirm only minimal/system objects (if any) remain:
Using kubectl
Using kubectl
Using kubectl
Run these commands from any machine with kubectl access.- List resources currently in the
defaultnamespace
default namespace is being used inappropriately.- Show all resource types in the
defaultnamespace, including non-pod objects
default indicate mixed or unclear segregation of resources.- Check which contexts default to the
defaultnamespace
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.- Inspect RBAC bindings tied to the
defaultnamespace
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.- Identify service accounts actively used in the
defaultnamespace
default often mean real applications are deployed there instead of in dedicated namespaces.- Verify whether key applications are running in non-default namespaces
app=frontend), check where they run: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.
Automation
Automation
- Any long-lived or production workload (Deployments, StatefulSets, DaemonSets, Jobs/CronJobs) listed under
defaultindicates a problem; these should be moved to dedicated namespaces. - Services, Ingresses, ConfigMaps, Secrets, and NetworkPolicies in
defaulttied to those workloads are also problematic and should be migrated with the workloads. - RoleBindings in
defaultand ClusterRoleBindings whosesubjectsreferencenamespace: defaultmay be overly broad; review whether access should instead be scoped to specific application namespaces. - Webhook, PSP, or other policy configurations that special-case
namespace: defaultshould be reviewed to ensure they are not encouraging or relying on use of the default namespace.

