> ## Documentation Index
> Fetch the complete documentation index at: https://orphelix.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Namespace Selection

> Filter resources by Kubernetes namespace and manage namespace access

## Overview

Namespaces provide logical isolation for Kubernetes resources. Orphelix allows you to filter views by namespace, switch between namespaces, and view resources across multiple namespaces.

![Namespace Selector](https://mintlify.s3.us-west-1.amazonaws.com/orphelix/images/namespace-selector.png)

## What are Namespaces?

Kubernetes namespaces partition cluster resources:

> [card] Isolation
>
> Separate resources by environment, team, or application

> [card] Access Control
>
> Apply RBAC policies per namespace

> [card] Resource Quotas
>
> Limit CPU/memory usage per namespace

> [card] Name Scoping
>
> Same resource names in different namespaces

### Default Namespaces

Every Kubernetes cluster has these namespaces:

> [accordion] default
>
> **Purpose:** Default namespace for resources without explicit namespace
>
> **Usage:** Development, testing, or small deployments
>
> **Best practice:** Don't use for production

> [accordion] kube-system
>
> **Purpose:** Kubernetes system components
>
> **Resources:**
>
> * kube-dns / CoreDNS
> * kube-proxy
> * Metrics server
> * Cloud provider components
>
> **Access:** Usually restricted to cluster admins

> [accordion] kube-public
>
> **Purpose:** Publicly readable resources
>
> **Usage:** ConfigMaps accessible cluster-wide
>
> **Rare use case**

> [accordion] kube-node-lease
>
> **Purpose:** Node heartbeat objects
>
> **Usage:** Internal Kubernetes node tracking
>
> **Don't modify**

## Namespace Selector

Switch namespaces from the header:

![Namespace Dropdown](https://mintlify.s3.us-west-1.amazonaws.com/orphelix/images/namespace-dropdown.png)

### Location

The namespace selector appears in two places:

1. **Header (top-right)**: Global namespace selection
2. **Mode selector dialog**: When switching from Demo to Real mode

### Selecting a Namespace

**1. Click Namespace Dropdown**

Click current namespace name in header

**2. Choose Namespace**

Select from list of available namespaces

![Namespace List](https://mintlify.s3.us-west-1.amazonaws.com/orphelix/images/namespace-list.png)

**3. Wait for Reload**

Resources reload for selected namespace (1-2 seconds)

**4. Verify**

Check header shows correct namespace

All pages now show resources from selected namespace

> [!NOTE]
>
> Namespace selection persists across browser sessions

### Namespace Information

Each namespace in the dropdown shows:

* **Name**: Namespace identifier
* **Status**: Active or Terminating
* **Resource Count**: Number of pods in namespace
* **Labels**: Important labels (environment, team, etc.)

**Example display:**

```
📦 production (25 pods)
   env=prod, team=platform

📦 staging (12 pods)
   env=staging, team=platform

📦 development (8 pods)
   env=dev, team=platform
```

## All Namespaces View

View resources across all namespaces:

> [tab] Enable
>
> **Option 1:** Select "All Namespaces" from dropdown
>
> **Option 2:** Check "All Namespaces" checkbox (where available)

> [tab] Behavior
>
> When enabled:
>
> * Lists resources from ALL accessible namespaces
>
> * Adds "Namespace" column to tables
>
> * Useful for cluster-wide overview
>
> > [!WARNING]
> >
> > Can be slow on large clusters with many namespaces

> [tab] Permissions
>
> Requires RBAC permissions:
>
> ```yaml theme={null}
> apiVersion: rbac.authorization.k8s.io/v1
> kind: ClusterRole
> metadata:
>   name: namespace-reader
> rules:
> - apiGroups: [""]
>   resources: ["namespaces"]
>   verbs: ["list", "get"]
> ```

## Namespace Details Page

View comprehensive namespace information:

![Namespace Detail](https://mintlify.s3.us-west-1.amazonaws.com/orphelix/images/namespace-detail.png)

### Overview Section

**1. Basic Information**

* **Name**: Namespace name
* **Status**: Active, Terminating
* **Created**: Creation timestamp
* **Labels**: All namespace labels
* **Annotations**: Namespace annotations

**2. Resource Counts**

Number of resources in namespace:

* Deployments
* StatefulSets
* DaemonSets
* Pods
* Services
* ConfigMaps
* Secrets
* HPAs

**3. Resource Quotas**

CPU/memory limits and usage:

![Resource Quotas](https://mintlify.s3.us-west-1.amazonaws.com/orphelix/images/namespace-quotas.png)

**Quota cards show:**

* CPU requests/limits
* Memory requests/limits
* Pod count limits
* PVC count/storage limits
* Current usage vs quota
* Percentage used (progress bar)

### Resource Quotas

Namespaces can have ResourceQuota objects limiting usage:

```yaml theme={null}
apiVersion: v1
kind: ResourceQuota
metadata:
  name: compute-quota
  namespace: production
spec:
  hard:
    requests.cpu: "10"
    requests.memory: "20Gi"
    limits.cpu: "20"
    limits.memory: "40Gi"
    pods: "50"
```

**Orphelix displays:**

> [tab] CPU Quota
>
> ```
> CPU Requests: 7.5 / 10 cores (75%)
> CPU Limits: 15 / 20 cores (75%)
>
> [████████████████████░░░░░] 75%
> ```
>
> * Green: \< 70% used
> * Yellow: 70-90% used
> * Red: > 90% used

> [tab] Memory Quota
>
> ```
> Memory Requests: 15 GB / 20 GB (75%)
> Memory Limits: 30 GB / 40 GB (75%)
>
> [████████████████████░░░░░] 75%
> ```

> [tab] Pod Count
>
> ```
> Pods: 42 / 50 (84%)
>
> [███████████████████████░░] 84%
> ```
>
> Warning when approaching limit

> [tab] Storage
>
> ```
> PVCs: 15 / 20 (75%)
> Storage: 450 GB / 500 GB (90%)
>
> [█████████████████████████] 90%
> ```

### Limit Ranges

LimitRange objects set default/min/max resource values:

```yaml theme={null}
apiVersion: v1
kind: LimitRange
metadata:
  name: resource-limits
  namespace: production
spec:
  limits:
  - type: Container
    default:
      cpu: "500m"
      memory: "512Mi"
    defaultRequest:
      cpu: "250m"
      memory: "256Mi"
    max:
      cpu: "2"
      memory: "2Gi"
    min:
      cpu: "100m"
      memory: "128Mi"
```

**Orphelix shows:**

* Default requests/limits (applied if not specified)
* Min/max values (prevents pods outside range)
* Affects new pods only (not existing)

## Creating Namespaces

> [tab] kubectl
>
> ```bash theme={null}
> kubectl create namespace production
> ```

> [tab] YAML
>
> ```yaml theme={null}
> apiVersion: v1
> kind: Namespace
> metadata:
>   name: production
>   labels:
>     environment: prod
>     team: platform
> ```
>
> Apply:
>
> ```bash theme={null}
> kubectl apply -f namespace.yaml
> ```

> [tab] With Quotas
>
> ```yaml theme={null}
> apiVersion: v1
> kind: Namespace
> metadata:
>   name: production
> ---
> apiVersion: v1
> kind: ResourceQuota
> metadata:
>   name: compute-quota
>   namespace: production
> spec:
>   hard:
>     requests.cpu: "10"
>     requests.memory: "20Gi"
>     pods: "50"
> ---
> apiVersion: v1
> kind: LimitRange
> metadata:
>   name: resource-limits
>   namespace: production
> spec:
>   limits:
>   - type: Container
>     default:
>       cpu: "500m"
>       memory: "512Mi"
>     defaultRequest:
>       cpu: "250m"
>       memory: "256Mi"
> ```

## Namespace Organization Strategies

### By Environment

```
namespaces:
  - development
  - staging
  - production
```

**Pros:**

* Clear environment separation
* Easy to understand
* Simple RBAC policies

**Cons:**

* Limited scalability
* All apps mixed per environment

### By Team

```
namespaces:
  - team-platform
  - team-frontend
  - team-backend
  - team-data
```

**Pros:**

* Team ownership clear
* Independent team workflows
* Isolated team quotas

**Cons:**

* Multiple deployments per team
* Cross-team dependencies complex

### By Application

```
namespaces:
  - app-api-gateway
  - app-user-service
  - app-order-service
  - app-payment-service
```

**Pros:**

* Clear app boundaries
* Easy to track app resources
* Independent scaling

**Cons:**

* Many namespaces
* Shared services complicated

### Hybrid (Environment + Application)

```
namespaces:
  - prod-api-gateway
  - prod-user-service
  - staging-api-gateway
  - staging-user-service
  - dev-api-gateway
  - dev-user-service
```

**Pros:**

* Complete isolation
* Clear environment + app
* Flexible RBAC

**Cons:**

* Namespace explosion
* Management overhead

## RBAC and Namespaces

Control who can access each namespace:

### Namespace-scoped Roles

```yaml theme={null}
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: developer
  namespace: development
rules:
- apiGroups: ["", "apps"]
  resources: ["pods", "deployments", "services"]
  verbs: ["get", "list", "watch", "create", "update", "delete"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: developers
  namespace: development
subjects:
- kind: Group
  name: developers
  apiGroup: rbac.authorization.k8s.io
roleRef:
  kind: Role
  name: developer
  apiGroup: rbac.authorization.k8s.io
```

**Effect:** Developers can manage resources in `development` namespace only

### Read-only Access

```yaml theme={null}
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: viewer
  namespace: production
rules:
- apiGroups: ["", "apps"]
  resources: ["*"]
  verbs: ["get", "list", "watch"]
```

**Effect:** View all resources but cannot modify

### Cross-namespace Access

```yaml theme={null}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: multi-namespace-viewer
rules:
- apiGroups: [""]
  resources: ["pods", "services"]
  verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: viewer-prod
  namespace: production
roleRef:
  kind: ClusterRole
  name: multi-namespace-viewer
  apiGroup: rbac.authorization.k8s.io
subjects:
- kind: User
  name: alice
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: viewer-staging
  namespace: staging
roleRef:
  kind: ClusterRole
  name: multi-namespace-viewer
  apiGroup: rbac.authorization.k8s.io
subjects:
- kind: User
  name: alice
```

**Effect:** Alice can view resources in both production and staging

## Best Practices

> [accordion] Use Descriptive Names
>
> Clear namespace naming convention:
>
> ✅ Good:
>
> * `prod-api-gateway`
> * `staging-user-service`
> * `dev-data-pipeline`
>
> ❌ Bad:
>
> * `ns1`
> * `test`
> * `myapp`

> [accordion] Apply Resource Quotas
>
> Prevent resource exhaustion:
>
> ```yaml theme={null}
> apiVersion: v1
> kind: ResourceQuota
> metadata:
>   name: quota
>   namespace: development
> spec:
>   hard:
>     requests.cpu: "10"
>     requests.memory: "20Gi"
>     pods: "50"
> ```

> [accordion] Set Default Limits
>
> Use LimitRanges for consistency:
>
> ```yaml theme={null}
> apiVersion: v1
> kind: LimitRange
> metadata:
>   name: defaults
>   namespace: production
> spec:
>   limits:
>   - type: Container
>     default:
>       memory: "512Mi"
>       cpu: "500m"
>     defaultRequest:
>       memory: "256Mi"
>       cpu: "250m"
> ```

> [accordion] Label Namespaces
>
> Add metadata for filtering/reporting:
>
> ```yaml theme={null}
> metadata:
>   labels:
>     environment: production
>     team: platform
>     cost-center: "12345"
>     compliance: pci-dss
> ```

> [accordion] Document Namespace Purpose
>
> Use annotations:
>
> ```yaml theme={null}
> metadata:
>   annotations:
>     description: "Production API Gateway service"
>     owner: "platform-team@example.com"
>     slack-channel: "#platform-alerts"
> ```

> [accordion] Don't Overuse Namespaces
>
> Balance isolation vs complexity:
>
> * Too few: No isolation
> * Too many: Management overhead
>
> Typical: 5-20 namespaces per cluster

## Troubleshooting

### Namespace Stuck in Terminating

**Symptom:** `kubectl delete namespace` hangs

**Cause:** Finalizers preventing deletion

**Solution:**

**1. Check Finalizers**

```bash theme={null}
kubectl get namespace <name> -o yaml
```

Look for `spec.finalizers`

**2. Remove Finalizers**

```bash theme={null}
kubectl get namespace <name> -o json \
  | jq '.spec.finalizers=[]' \
  | kubectl replace --raw "/api/v1/namespaces/<name>/finalize" -f -
```

**3. Force Delete**

If still stuck:

```bash theme={null}
kubectl delete namespace <name> --force --grace-period=0
```

### Resource Quota Exceeded

**Symptom:** Cannot create pods - "exceeded quota"

**Check:**

```bash theme={null}
kubectl describe resourcequota -n <namespace>
```

**Solutions:**

1. **Increase Quota**
   ```bash theme={null}
   kubectl edit resourcequota compute-quota -n <namespace>
   ```

2. **Delete Unused Resources**
   ```bash theme={null}
   kubectl delete deployment <old-deployment> -n <namespace>
   ```

3. **Reduce Resource Requests**
   ```yaml theme={null}
   resources:
     requests:
       cpu: "250m"  # Was 500m
       memory: "256Mi"  # Was 512Mi
   ```

### Cannot Access Namespace

**Symptom:** "Forbidden" errors

**Check RBAC:**

```bash theme={null}
kubectl auth can-i get pods -n <namespace>
```

**Solution:** Request access from cluster admin

## Next Steps

> [card] [Cluster Connection](https://orphelix.mintlify.site/user/configuration/cluster-connection.md)
>
> Configure cluster access

> [card] [Settings](https://orphelix.mintlify.site/user/configuration/settings.md)
>
> Customize Orphelix settings

> [card] [Deployments](https://orphelix.mintlify.site/user/deployments.md)
>
> View namespace resources

> [card] [Dashboard](https://orphelix.mintlify.site/user/dashboard.md)
>
> Monitor namespace usage


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.