Skip to main content
Version: v5.0 Stable

Isolation

Platform-managed namespaces are deprecated

Namespaces managed through projects, also known as spaces, are deprecated in v5.0.0. Platform management of namespaces is planned for removal in a later v5.0 patch release. Existing Kubernetes namespaces and their workloads will remain on their clusters after removal. The platform will no longer manage them.

Until then, platform-managed namespaces keep working in projects outside tenants. Tenant projects can't create or import them, and they can't be moved into a tenant project. Move workloads that need continued platform management to clusters.

Namespaces can be configured to provide moderate levels of isolation. This "isolation" typically includes applying ResourceQuotas, LimitRanges, and NetworkPolicies to a Namespace. These policies can be configured using the Space Template Objects option, to provide your desired quotas, limits, and network policies. To make your life easier, vCluster Platform is deployed with a default Space Template called Isolated Space Template. This space template can give you a head start on configuring your own namespace isolation policies, or you may find the template sufficient for your needs.

Default isolated space template​

The Isolated Space Template applies three resources:

  • ResourceQuota: Limits namespace to 10 CPU cores (20 max), 20Gi memory (40Gi max), 100Gi storage, 20 pods
  • LimitRange: Sets container defaults (20m CPU, 64Mi memory) and limits (2 CPU, 4Gi memory)
  • NetworkPolicy: Restricts egress to DNS and platform services, blocks private IP ranges

Configure namespace objects​

The Objects field in a space template defines Kubernetes resources to create in each namespace.

Example: Custom isolation configuration​

apiVersion: management.loft.sh/v1
kind: SpaceTemplate
metadata:
name: dev-team-isolated
spec:
displayName: Development Team Isolated Space
description: Isolated space template for development teams with moderate resource limits
access:
- users:
- '*'
verbs:
- get
template:
metadata: {}
instanceTemplate:
metadata: {}
objects: |
# ResourceQuota for development environments
apiVersion: v1
kind: ResourceQuota
metadata:
name: dev-resource-quota
spec:
hard:
requests.cpu: "4" # Total CPU requests limited to 4 cores
requests.memory: "8Gi" # Total memory requests limited to 8GB
limits.cpu: "8" # Total CPU limits cannot exceed 8 cores
limits.memory: "16Gi" # Total memory limits cannot exceed 16GB
persistentvolumeclaims: "10" # Maximum 10 PVCs
services.loadbalancers: "2" # Maximum 2 LoadBalancer services
count/deployments.apps: "20" # Maximum 20 deployments
count/pods: "50" # Maximum 50 pods
---
# LimitRange for container defaults
apiVersion: v1
kind: LimitRange
metadata:
name: dev-limit-range
spec:
limits:
- type: Container
default:
cpu: "500m" # Default CPU limit if not specified
memory: "1Gi" # Default memory limit if not specified
defaultRequest:
cpu: "100m" # Default CPU request
memory: "128Mi" # Default memory request
max:
cpu: "2" # Single container max 2 cores
memory: "4Gi" # Single container max 4GB
min:
cpu: "10m" # Minimum CPU per container
memory: "32Mi" # Minimum memory per container
---
# NetworkPolicy with more permissive rules for development
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: dev-network-policy
spec:
podSelector: {} # Apply to all pods in namespace
policyTypes:
- Egress
- Ingress
ingress:
- from:
- podSelector: {} # Allow all traffic within namespace
- namespaceSelector:
matchLabels:
loft.sh/allow-traffic: 'true' # Allow from platform services
egress:
- to:
- podSelector: {} # Allow to all pods in namespace
- ports: # Allow DNS
- port: 53
protocol: UDP
- port: 53
protocol: TCP
- to: # Allow external HTTPS/HTTP for development
- namespaceSelector: {}
- ipBlock:
cidr: 0.0.0.0/0
except: # Block local networks except for specific needs
- 169.254.0.0/16
ports:
- protocol: TCP
port: 443
- protocol: TCP
port: 80

The objects field accepts a yaml string with Kubernetes resources separated by ---.

CNIs and Network Policies

Not all CNIs will support all network policies. Make sure you understand what capabilities your CNI supports when investigating namespace isolation.

To enforce storage limits inside a cluster, including per-PVC size caps and storage class restrictions, see Enforce storage quotas per cluster.