From kubernetes
Provision and sync Kubernetes tenant namespaces — ResourceQuota, LimitRange, NetworkPolicy (default-deny), and coordinate labels — from a compute-design.md and tenant.yaml definitions. Uses the Kubernetes MCP server. Use when onboarding a new tenant, applying quota changes, or enforcing namespace guardrails after running design-compute.
How this skill is triggered — by the user, by Claude, or both
Slash command
/kubernetes:manage-k8s-namespacesThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Implementation
Implementation
v1, networking.k8s.io).v1/namespaces: create, update, get, listv1/resourcequotas: create, update, delete, get, listv1/limitranges: create, update, delete, get, listnetworking.k8s.io/networkpolicies: create, update, delete, get, listmanage-k8s-iam, not this skill.Provision and maintain tenant namespaces in a Kubernetes cluster — each pre-configured with the platform guardrails required by the compute design. Ensure that:
This skill does not manage RBAC (RoleBindings) — use manage-k8s-iam for that.
This skill is idempotent.
When writing configurations or documentation, you MUST strictly adhere to the structural notation and types defined in the book. Before proceeding, read the following reference files:
references/notation.mdreferences/types.mdBefore proceeding, ask the user (or infer from context):
compute-design.md. Read it to get the quota templates and LimitRange defaults.tenants/{name}.yaml. One namespace is created per tenant per cluster.{tenant} if the cluster is already tier-scoped, or {tenant}-{tier} if multi-tier.) Derive from the naming convention.Read all input documents before proceeding.
Read compute-design.md and the relevant tenants/{name}.yaml files. Extract:
Validate:
For each tenant:
labels:
mountainlab.io/tenant: payments
mountainlab.io/sector: ecommerce
mountainlab.io/tier: live
mountainlab.io/region: eu01
mountainlab.io/quota-template: medium
Do not delete namespaces not in the tenant list without explicit user confirmation — namespace deletion removes all resources inside it.
For each tenant namespace, apply the ResourceQuota from the assigned quota template:
apiVersion: v1
kind: ResourceQuota
metadata:
name: tenant-quota
namespace: payments
spec:
hard:
requests.cpu: "16"
limits.cpu: "32"
requests.memory: 32Gi
limits.memory: 64Gi
requests.storage: 100Gi
persistentvolumeclaims: "20"
pods: "100"
services: "20"
secrets: "50"
configmaps: "50"
For each quota:
ResourceQuota named tenant-quota exists in the namespace.Quota reductions are breaking changes: If a quota is being reduced below the namespace's current resource usage, the existing workloads are not affected immediately, but new resource requests will fail. Warn the user before applying a reduction and recommend checking current usage first.
For each tenant namespace, apply the LimitRange that injects default resource requests and limits into containers that don't specify them:
apiVersion: v1
kind: LimitRange
metadata:
name: tenant-limits
namespace: payments
spec:
limits:
- type: Container
defaultRequest:
cpu: "100m"
memory: "128Mi"
default:
cpu: "500m"
memory: "512Mi"
max:
cpu: "4"
memory: "8Gi"
The max values prevent a single container from claiming more than a reasonable fraction of the quota, providing basic protection against runaway resource consumption.
For each LimitRange:
For each tenant namespace, apply a default-deny policy for both ingress and egress. This forces application teams to explicitly define which traffic their services allow.
Default deny all ingress:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: default-deny-ingress
namespace: payments
spec:
podSelector: {}
policyTypes:
- Ingress
Default deny all egress:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: default-deny-egress
namespace: payments
spec:
podSelector: {}
policyTypes:
- Egress
Platform allow-list (add these in addition to the deny rules):
kube-dns in kube-system, UDP 53):apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-dns-egress
namespace: payments
spec:
podSelector: {}
policyTypes:
- Egress
egress:
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: kube-system
ports:
- protocol: UDP
port: 53
- protocol: TCP
port: 53
Application teams are responsible for adding further NetworkPolicy rules to allow their service-to-service traffic. The platform provides the default-deny floor and the DNS allow-list.
For each NetworkPolicy:
After applying, verify each namespace's state:
Report any namespace where current usage exceeds 80% of the quota limit — these are candidates for a quota increase request.
Produce a summary.
Produce a Markdown report named k8s-namespaces-report.md:
# Kubernetes Namespace Sync Report
**Date**: [timestamp]
**Cluster**: [cluster context name]
**Mode**: [applied / dry-run]
## Namespaces
| Namespace | Tenant | Quota Template | Status |
|-----------|--------|---------------|--------|
| payments | payments | medium | created |
| recommendations | recommendations | small | exists (labels updated) |
## ResourceQuotas
| Namespace | Template | CPU Req | Mem Req | Status |
|-----------|----------|---------|---------|--------|
| payments | medium | 16 | 32Gi | created |
| recommendations | small | 8 | 16Gi | exists (no change) |
## LimitRanges
| Namespace | Status |
|-----------|--------|
| payments | created |
| recommendations | exists |
## NetworkPolicies
| Namespace | Policy | Status |
|-----------|--------|--------|
| payments | default-deny-ingress | created |
| payments | default-deny-egress | created |
| payments | allow-dns-egress | created |
## Quota Usage Warnings
| Namespace | Resource | Current Usage | Limit | % Used |
|-----------|---------|--------------|-------|--------|
| recommendations | memory requests | 13Gi | 16Gi | 81% |
## Namespaces Not in Tenant List (Orphans)
| Namespace | Action |
|-----------|--------|
| legacy-payments | Not managed — confirm before deletion |
## Open Items
[Quota reduction warnings, network policy CNI compatibility notes, etc.]
manage-k8s-iam.This skill is grounded in Chapter 6: Infrastructure of Crafting Platforms.
npx claudepluginhub craftingplatforms/ai --plugin kubernetesConfigures Kubernetes RBAC, service accounts, namespaces, resource quotas, and service types for least-privilege pod access. Useful when writing or auditing Deployments, ServiceAccounts, Roles, and RoleBindings.
Configures Kubernetes RBAC to enforce least privilege access on cluster resources. Covers Role/ClusterRole design, RoleBinding setup, service account security, namespace isolation, and audit logging for multi-tenant clusters.
<!-- AUTO-GENERATED by export-plugins.py — DO NOT EDIT -->