More Info:
Use namespaces to isolate your Kubernetes objects.Risk Level
LowAddress
SecurityCompliance Standards
- CIS Kubernetes
Triage and Remediation
- Remediation
Remediation
Manual Steps
Manual Steps
-
Inventory current namespaces and workloads
Run on: any machine with kubectl accessReview whether application, platform, and system components are clearly separated (for example:kube-system,monitoring,logging,team-a,team-b, etc.). -
Map workloads to teams/environments and desired boundaries
Run on: any machine with kubectl accessFor each workload, decide which administrative boundary it should belong to (per team, per environment like dev/stage/prod, per application, or per data classification). Document the target namespace layout (e.g.,team-a-dev,team-a-prod,shared-infra). -
Identify objects in inappropriate or overly shared namespaces
Run on: any machine with kubectl accessFlag any non-system workloads running indefaultor in a namespace that does not match the intended boundary from step 2. -
Define or create the required namespaces
Run on: any machine with kubectl access
For each desired namespace that does not yet exist:Optionally prepare namespace manifests for GitOps/IaC:Apply with: -
Plan and execute workload relocation into proper namespaces
Run on: any machine with kubectl access
For each object identified in step 3, update its manifest to setmetadata.namespace: <target-namespace>and re-apply:Repeat similarly for services, configmaps, secrets, ingresses, and other namespaced resources, ensuring references (service names, configMapRefs, secretRefs, PVCs) remain valid in the new namespace. -
Verify namespace-based boundaries are in place
Run on: any machine with kubectl accessConfirm that:defaultcontains no long-lived application workloads unless explicitly intended.- Workloads are grouped into namespaces that reflect the documented administrative boundaries (teams, environments, or applications) and that cross-team/environment sharing is limited to explicitly designated shared namespaces.
Using kubectl
Using kubectl
Using kubectl
1. List all namespaces and their basic metadata
Run on: any machine with kubectl access- Only
defaultplus system namespaces (kube-system,kube-public,kube-node-lease, any cloud-provider system namespaces) in a busy cluster. - Many unrelated apps or teams apparently all using
default.
2. See what is running in each namespace
Run on: any machine with kubectl access- Multiple unrelated applications (different teams, environments, or tenants) mixed in the same non-system namespace.
- Business-critical workloads running in
default.
3. Inventory higher-level objects by namespace
Run on: any machine with kubectl accessWorkloads:- Namespaces that act as “junk drawers” for many unrelated workloads/configs.
- Shared namespace holding both production and non-production resources.
- Shared namespace used by multiple teams/tenants (you’ll identify this by naming conventions or labels from your environment).
4. Check for labeling that reflects ownership or environment
Run on: any machine with kubectl access- No labels reflecting owner/team, environment (
prod,dev,test), or tenant where that separation is expected in your organization. - Single namespace apparently serving multiple environments or tenants based on object names inside it (e.g.,
prod-*anddev-*resources mixed together).
5. Review access control by namespace (for context)
While this check is about namespaces themselves, RBAC use can show whether namespaces are being used as an administrative boundary.Run on: any machine with kubectl access- Heavy use of
ClusterRoleBindingto grant broad access, instead ofRoleBindingscoped to specific namespaces, suggesting that namespaces are not being used as boundaries. - Same service account or user bound to roles across many unrelated namespaces without a clear reason.
6. Focus review on the default namespace
Run on: any machine with kubectl access- Application workloads from multiple teams or environments all live in
default. - Critical workloads live in
defaultinstead of a clearly named, dedicated namespace.
kubectl cannot decide the correct namespace design for you. Use the above outputs to determine whether your current namespace layout reflects your organizational boundaries (teams, tenants, environments, or applications) and adjust your manifests and deployment processes accordingly.
Automation
Automation
- Run on any machine with
kubectlandjqinstalled and access to the cluster:
- Namespaces where:
- Many unrelated apps and teams share the same namespace.
- Application pods are present in
kube-systemor other system namespaces. - Critical shared services live only in
default. - Only the
defaultServiceAccount is used for many workloads. - There are many workloads but zero
NetworkPolicies. - ClusterRoleBindings grant broad privileges to subjects from many namespaces.

