Skip to main content

More Info:

Verifies the default namespace has no workloads so RBAC, quotas and NetworkPolicies can be scoped per tenant.

Risk Level

Medium

Address

Security

Compliance Standards

  • Cloudanix Best Practice

Triage and Remediation

Remediation

Manual Steps

  1. List all workloads in the default namespace (run on any machine with kubectl access):
  2. For each workload type in default, export its manifests to files so you can recreate them in a new namespace (replace WORKLOAD and NAME accordingly; run on any machine with kubectl access):
  3. Edit each exported manifest file to set a purpose-specific namespace and remove default-assigned fields (run on any machine with kubectl access):
    • In each YAML file, under metadata, set:
    • Remove the following fields if present to avoid conflicts when recreating:
      • metadata: { uid, resourceVersion, selfLink, creationTimestamp, managedFields, ownerReferences }
      • status sections
    • Save the edited files.
  4. Create the new namespace if it does not already exist (run on any machine with kubectl access):
  5. Recreate workloads in the new namespace, then delete them from default (run on any machine with kubectl access):
  6. Verification (run on any machine with kubectl access):
    Confirm that podCount=0 and is_compliant=true.
On any machine with kubectl access:
  1. Identify all workloads in the default namespace
  1. For each workload type, export its manifest from default and save it to a file, then edit the namespace field.
Example for a deployment named my-app:
  1. Create the target namespace if it does not already exist:
  1. Apply the updated manifest into the new namespace:
  1. Once you have recreated all needed workloads in their new, purpose-specific namespaces and confirmed they are running correctly, delete the originals from the default namespace.
Examples by resource type:
Repeat this export–edit–apply–delete process for every workload that currently runs in the default namespace, moving each into an appropriate purpose-specific namespace.
  1. Verification (pod count in default should be zero):