Skip to main content
New: the Agentic AI Academy, 5 courses on running AI agents in production.Start free →

Tenants and owners with Capsule

This is the free lesson

Next: What an owner can and cannot do

The rest of this course is part of Pro, together with every other course and the ones added later.

$25 a month billed yearly, or $29 month to month

Until 30 November: $210 for the first year, or $14.50 for the first month, with code LAUNCH.

A free account keeps your progress across devices. The paid lessons need Pro.

Code Snippets

cluster.yamlyaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: tenancy
nodes:
  - role: control-plane
    kubeadmConfigPatches:
      - |
        kind: ClusterConfiguration
        apiServer:
          extraArgs:
            - name: enable-admission-plugins
              value: NodeRestriction,PodNodeSelector
  - role: worker
    labels:
      pool: search
  - role: worker
    labels:
      pool: billing
tenants.yamlyaml
apiVersion: capsule.clastix.io/v1beta2
kind: Tenant
metadata:
  name: search
spec:
  owners:
    - kind: User
      name: alice
  nodeSelector:
    pool: search
---
apiVersion: capsule.clastix.io/v1beta2
kind: Tenant
metadata:
  name: billing
spec:
  owners:
    - kind: User
      name: bob
  nodeSelector:
    pool: billing
Commands of this lessonbash
docker info --format '{{.NCPU}} CPUs' && kind version
kind create cluster --config cluster.yaml
kubectl wait --for=condition=Ready nodes --all --timeout=120s
kubectl get nodes -L pool
kubectl get pod -n kube-system kube-apiserver-tenancy-control-plane -o yaml | grep admission
helm install cert-manager oci://quay.io/jetstack/charts/cert-manager --version v1.21.3 \
  -n cert-manager --create-namespace --set crds.enabled=true --wait
helm repo add projectcapsule https://projectcapsule.github.io/charts
helm install capsule projectcapsule/capsule --version 0.15.2 \
  -n capsule-system --create-namespace --wait
kubectl get capsuleconfiguration default -o jsonpath='{.spec.users}{"\n"}'
kubectl apply -f tenants.yaml
kubectl get tenants
kubectl create namespace search-dev --as alice --as-group projectcapsule.dev
kubectl create namespace billing-dev --as bob --as-group projectcapsule.dev
kubectl get namespaces -l capsule.clastix.io/tenant -L capsule.clastix.io/tenant
kubectl get namespace search-dev -o jsonpath='{.metadata.annotations}{"\n"}'
kubectl create deployment web --image nginx:1.29 -n billing-dev --as alice --as-group projectcapsule.dev
kubectl create namespace carol-dev --as carol
kubectl get tenants