Loading...
Loading...
Use when provisioning new tenant namespaces, configuring tenant RBAC roles and bindings, setting up resource quotas and limits, implementing network isolation between tenants, managing tenant lifecycle (onboarding/offboarding), or designing self-service provisioning
npx skill4agent add foxj77/claude-code-skills k8s-platform-tenancy| Task | Command |
|---|---|
| List tenants | |
| Check quota | |
| Audit RBAC | |
| View policies | |
cluster/
├── platform-system/ # Platform team only
│ ├── monitoring/
│ ├── ingress/
│ └── cert-manager/
├── tenant-alpha/ # Tenant workloads
├── tenant-beta/
└── tenant-gamma/apiVersion: v1
kind: Namespace
metadata:
name: tenant-${TENANT_NAME}
labels:
platform.io/tenant: ${TENANT_NAME}
platform.io/environment: ${ENV}
platform.io/cost-center: ${COST_CENTER}
platform.io/tier: ${TIER}
pod-security.kubernetes.io/enforce: restricted
pod-security.kubernetes.io/audit: restricted
pod-security.kubernetes.io/warn: restricted
annotations:
platform.io/owner: ${OWNER_EMAIL}
platform.io/created: ${DATE}
platform.io/expires: ${EXPIRY_DATE} # Optional for temp namespacesapiVersion: v1
kind: ResourceQuota
metadata:
name: tenant-quota
spec:
hard:
requests.cpu: "5"
requests.memory: 10Gi
limits.cpu: "10"
limits.memory: 20Gi
persistentvolumeclaims: "5"
services.loadbalancers: "1"
count/pods: "25"spec:
hard:
requests.cpu: "10"
requests.memory: 20Gi
limits.cpu: "20"
limits.memory: 40Gi
persistentvolumeclaims: "10"
services.loadbalancers: "2"
count/pods: "50"spec:
hard:
requests.cpu: "20"
requests.memory: 40Gi
limits.cpu: "40"
limits.memory: 80Gi
persistentvolumeclaims: "20"
services.loadbalancers: "5"
count/pods: "100"apiVersion: v1
kind: LimitRange
metadata:
name: tenant-limits
spec:
limits:
- type: Container
default:
cpu: 500m
memory: 512Mi
defaultRequest:
cpu: 100m
memory: 128Mi
max:
cpu: "4"
memory: 8Gi
min:
cpu: 50m
memory: 64Mi
- type: PersistentVolumeClaim
max:
storage: 100Gi
min:
storage: 1GiapiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: tenant-admin
rules:
- apiGroups: ["", "apps", "batch"]
resources: ["*"]
verbs: ["*"]
- apiGroups: ["networking.k8s.io"]
resources: ["ingresses", "networkpolicies"]
verbs: ["*"]
- apiGroups: ["autoscaling"]
resources: ["horizontalpodautoscalers"]
verbs: ["*"]apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: tenant-developer
rules:
- apiGroups: ["", "apps", "batch"]
resources: ["pods", "deployments", "services", "configmaps", "secrets"]
verbs: ["get", "list", "watch", "create", "update", "patch"]
- apiGroups: [""]
resources: ["pods/log", "pods/exec"]
verbs: ["get", "create"]default-deny-allallow-dnsallow-same-namespaceallow-ingress-controllerallow-prometheus-scrapeapiVersion: platform.io/v1
kind: TenantRequest
metadata:
name: new-tenant-request
spec:
tenantName: alpha
tier: silver
owner: team-alpha@company.com
costCenter: CC-1234
environments:
- dev
- staging
- prod| Tier | CPU | Memory | Storage | Support | SLA |
|---|---|---|---|---|---|
| Bronze | 5 | 10Gi | 50Gi | Best effort | None |
| Silver | 10 | 20Gi | 200Gi | Business hours | 99% |
| Gold | 20 | 40Gi | 500Gi | 24/7 | 99.5% |
| Platinum | Custom | Custom | Custom | Dedicated | 99.9% |
| Mistake | Why It Fails | Instead |
|---|---|---|
Granting | Tenants can modify NetworkPolicies or ResourceQuotas, breaking isolation | Enumerate specific resources and verbs per role |
| Forgetting default LimitRange on new namespaces | Pods without resource requests get best-effort QoS and are evicted first | Always pair ResourceQuota with a LimitRange |
Using | Anyone can relabel a namespace and bypass tenant scoping | Enforce labels with admission control (Kyverno/OPA) |
| Skipping NetworkPolicy on "internal-only" namespaces | Compromised pod in one tenant can reach all others | Apply default-deny + explicit allow to every tenant namespace |
| Deleting namespace before revoking RBAC | Tenant users see confusing errors; orphaned ClusterRoleBindings remain | Revoke bindings first, then delete namespace (follow offboarding checklist) |
# Using kubectl via MCP
mcp__flux-operator-mcp__get_kubernetes_resources
mcp__flux-operator-mcp__apply_kubernetes_manifest