DEV Community

ANKUSH CHOUDHARY JOHAL
ANKUSH CHOUDHARY JOHAL

Posted on • Originally published at johal.in

How to Implement Kubernetes 1.32 Multi-Tenancy with Capsule 1.3 and Kyverno 1.12 for 2026 SaaS

How to Implement Kubernetes 1.32 Multi-Tenancy with Capsule 1.3 and Kyverno 1.12 for 2026 SaaS

The shift toward 2026 SaaS architectures demands robust, scalable multi-tenancy in Kubernetes (K8s) to isolate customer data, enforce security policies, and optimize resource usage. Kubernetes 1.32 introduces enhanced namespace and RBAC capabilities, while Capsule 1.3 simplifies tenant lifecycle management and Kyverno 1.12 delivers policy-as-code enforcement. This guide walks through a production-ready implementation.

Why Multi-Tenancy for 2026 SaaS?

2026 SaaS platforms will serve thousands of tenants with varying compliance, performance, and security requirements. Traditional single-tenant clusters are cost-prohibitive, while naive namespace-based multi-tenancy lacks isolation. A purpose-built stack combining K8s 1.32, Capsule 1.3, and Kyverno 1.12 addresses these gaps:

  • Capsule 1.3: Manages tenant abstraction via custom resources (CRs), automates namespace creation, and enforces tenant-level RBAC and resource quotas.
  • Kyverno 1.12: Enforces policy-as-code for tenant isolation, image security, network rules, and compliance without modifying application manifests.
  • Kubernetes 1.32: Adds native support for hierarchical namespaces, improved resource quota scoping, and enhanced API priority and fairness for multi-tenant workloads.

Prerequisites

  • A running Kubernetes 1.32 cluster (minimum 3 worker nodes for production)
  • kubectl v1.32+ configured to access the cluster
  • Helm v3.14+ installed
  • Administrative access to the cluster

Step 1: Install Capsule 1.3

Capsule provides tenant abstraction via the Tenant CRD. Install it using Helm:

helm repo add capsule https://clastix.github.io/charts
helm repo update
helm install capsule capsule/capsule --version 1.3.0 --namespace capsule-system --create-namespace
Enter fullscreen mode Exit fullscreen mode

Verify the installation:

kubectl get pods -n capsule-system
# Expected output: capsule-controller-manager-xxxx running
Enter fullscreen mode Exit fullscreen mode

Step 2: Configure Capsule Tenants

Create a tenant CR for a sample SaaS customer. Capsule automatically creates namespaces, applies resource quotas, and assigns tenant admins:

apiVersion: capsule.clastix.io/v1beta1
kind: Tenant
metadata:
  name: saas-customer-1
spec:
  owners:
  - name: admin@saas-customer-1.com
    kind: User
  resourceQuotas:
  - hard:
      cpu: "100"
      memory: 200Gi
      pods: "50"
  storageClasses:
  - standard
  allowedIngressClasses:
  - nginx
Enter fullscreen mode Exit fullscreen mode

Apply the manifest:

kubectl apply -f tenant.yaml
Enter fullscreen mode Exit fullscreen mode

Capsule will create the tenant namespace saas-customer-1 and assign the specified owner RBAC permissions.

Step 3: Install Kyverno 1.12

Kyverno enforces policies across all tenants. Install Kyverno 1.12 via Helm:

helm repo add kyverno https://kyverno.github.io/kyverno/
helm repo update
helm install kyverno kyverno/kyverno --version 1.12.0 --namespace kyverno --create-namespace
Enter fullscreen mode Exit fullscreen mode

Verify the Kyverno deployment:

kubectl get pods -n kyverno
# Expected output: kyverno-xxxx running
Enter fullscreen mode Exit fullscreen mode

Step 4: Implement Kyverno Policies for Multi-Tenancy

Create Kyverno policies to enforce tenant isolation and security. Below is a policy to restrict pods to tenant-specific namespaces:

apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: restrict-tenant-namespaces
spec:
  validationFailureAction: Enforce
  rules:
  - name: restrict-pod-placement
    match:
      any:
      - resources:
          kinds:
          - Pod
    validate:
      message: "Pods must run in namespaces labeled with capsule.clastix.io/tenant"
      pattern:
        metadata:
          namespace: "?*"
        spec:
          containers:
          - name: "?*"
  - name: enforce-tenant-label
    match:
      any:
      - resources:
          kinds:
          - Namespace
    mutate:
      patchStrategicMerge:
        metadata:
          labels:
            capsule.clastix.io/tenant: "{{request.object.metadata.name}}"
    preconditions:
      any:
      - key: "{{request.object.metadata.labels.capsule.clastix.io/tenant || ''}}"
        operator: Equals
        value: ""
Enter fullscreen mode Exit fullscreen mode

Apply the policy:

kubectl apply -f tenant-isolation-policy.yaml
Enter fullscreen mode Exit fullscreen mode

Step 5: Integrate Capsule and Kyverno

Capsule automatically labels tenant namespaces with capsule.clastix.io/tenant: <tenant-name>. Use this label in Kyverno policies to scope enforcement per tenant. For example, a policy to enforce resource limits for saas-customer-1:

apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: saas-customer-1-resource-limits
spec:
  validationFailureAction: Enforce
  rules:
  - name: require-resource-limits
    match:
      any:
      - resources:
          kinds:
          - Pod
          namespaces:
          - saas-customer-1
    validate:
      message: "CPU and memory limits are required for all containers"
      pattern:
        spec:
          containers:
          - resources:
              limits:
                cpu: "?*"
                memory: "?*"
Enter fullscreen mode Exit fullscreen mode

Step 6: Test the Multi-Tenancy Setup

Impersonate the tenant admin and deploy a sample application:

kubectl impersonate user admin@saas-customer-1.com -- kubectl run nginx --image=nginx:1.25 -n saas-customer-1
Enter fullscreen mode Exit fullscreen mode

Verify isolation: Attempt to deploy a pod in another tenant’s namespace, which should fail. Check Kyverno policy reports:

kubectl get policyreport -n saas-customer-1
Enter fullscreen mode Exit fullscreen mode

Step 7: Scale for 2026 SaaS

To support 2026 SaaS scale (10,000+ tenants):

  • Automate tenant onboarding via CI/CD pipelines using Capsule CRs.
  • Integrate Kyverno with OPA for advanced compliance policies.
  • Use K8s 1.32’s hierarchical namespaces for nested tenant structures.
  • Deploy monitoring (Prometheus) and cost allocation (Kubecost) per tenant.

Conclusion

Combining Kubernetes 1.32, Capsule 1.3, and Kyverno 1.12 delivers a secure, scalable multi-tenancy stack for 2026 SaaS platforms. This setup enforces tenant isolation, automates policy enforcement, and reduces operational overhead as you scale to thousands of tenants.

Top comments (0)