Skip to main content

More Info:

Using the default namespace for user resources hampers resource segregation and fine-grained RBAC. Move user-defined objects into dedicated namespaces.

Risk Level

Low

Address

Security

Compliance Standards

  • CIS EKS

Triage and Remediation

Remediation

Manual Steps

  1. Identify user resources in the default namespace
    • Run on: any machine with kubectl access
  2. Create one or more dedicated namespaces to move resources into
    • Run on: any machine with kubectl access
  3. Move workload resources (Deployments, StatefulSets, Services, etc.) out of default
    • Run on: any machine with kubectl access
      Export each object from default, remove cluster-assigned fields, and re-create it in the new namespace. Example for a Deployment:
    Repeat this pattern for other namespaced resource kinds (e.g., statefulset, daemonset, service, ingress, cronjob, job, configmap, secret, pvc), adjusting the kind and name in the commands.
  4. Update references that point to the default namespace
    • Run on: any machine with kubectl access
      Search manifests or Helm values you use to deploy resources and update any explicit namespace: default fields, or -n default CLI flags, to the new namespace:
    Redeploy with the corrected manifests/Helm charts so future resources are created in the dedicated namespaces.
  5. Review and adjust RBAC for new namespaces
    • Run on: any machine with kubectl access
      Bind roles to users/service accounts in the new namespaces instead of default. Example:
  6. Verify no user resources remain in the default namespace
    • Run on: any machine with kubectl access
On any machine with kubectl access:
  1. Identify user resources in the default namespace
  1. For each resource type, decide a target namespace and create it if needed (example: team-a)
  1. Move namespaced resources out of default using kubectl get -o yaml | sed | kubectl apply
Example for Deployments:
Example for Services (be careful with in-cluster DNS names and consumers):
Example for ConfigMaps:
Example for Secrets (excluding default service account tokens; filter by name as needed):
Repeat the same pattern for other resource kinds present in default (e.g., statefulset, job, cronjob, ingress, role, rolebinding, networkpolicy, etc.):
  1. Verification (same logic as the audit):