Skill v1.0.1
currentAutomated scan100/100+3 new
version: "1.0.1" name: gke-multitenancy description: >- Plans and configures multi-tenancy on GKE. Covers namespace isolation, RBAC planning for teams, resource quotas, LimitRanges, network isolation, and cost allocation. Use when designing GKE multi-tenancy, configuring GKE namespaces, setting up resource quotas, or isolating GKE teams. Don't use for single-tenant cluster configuration or general deployment instructions (use gke-basics or gke-app-onboarding instead). metadata: category: Containers
GKE Multi-Tenancy
This reference covers enterprise multi-tenancy patterns on GKE, including namespace isolation, RBAC planning, resource quotas, and network segmentation.
MCP Tools:get_k8s_resource,check_k8s_auth,describe_k8s_resourceA change goes out as a pull request to the GitOps repository, never as a write from here: Kubernetes objects as YAML throughgke-manifest-generation, cluster settings and other Google Cloud resources as Config Connector YAML throughgcp-config-connector, opened withsubmit-suggestion. Each profile's config offers only thegkeMCP server's read tools, and the broker refuseskubectlandgcloudwrites.
When to Use
- Multiple teams sharing a single GKE cluster
- Isolating workloads by environment (dev/staging/prod) within one cluster
- Implementing least-privilege access control
- Cost allocation across teams or projects
Multi-Tenancy Models
| Model | Isolation | Complexity | Cost | |
|---|---|---|---|---|
| Namespace-per-team | Soft (RBAC + | Low | Lowest (shared |
: : Network : : cluster) : : : Policy) : : :
| Namespace-per-environment | Soft | Low | Low | |
|---|---|---|---|---|
| Node pool-per-team | Medium | Medium | Medium |
: : (dedicated : : : : : compute) : : :
: : isolation) : : :
Golden path recommendation: Start with namespace-per-team for costefficiency. Escalate to stronger isolation only when compliance requires it.
Namespace Isolation Setup
1. Create Namespaces
The namespaces are proposed as a pull request through submit-suggestion:
apiVersion: v1kind: Namespacemetadata:name: team-alabels:team: a---apiVersion: v1kind: Namespacemetadata:name: team-blabels:team: b
2. RBAC Configuration
Principle: Grant minimal permissions per namespace. Never bind to system:authenticated.
# Namespace-scoped role for a teamapiVersion: rbac.authorization.k8s.io/v1kind: Rolemetadata:name: team-a-developernamespace: team-arules:- apiGroups: ["", "apps", "batch"]resources: ["pods", "deployments", "services", "configmaps", "jobs"]verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]---apiVersion: rbac.authorization.k8s.io/v1kind: RoleBindingmetadata:name: team-a-developersnamespace: team-asubjects:- kind: Groupname: "team-a@example.com" # Google GroupapiGroup: rbac.authorization.k8s.ioroleRef:kind: Rolename: team-a-developerapiGroup: rbac.authorization.k8s.io
RBAC best practices: Use Google Groups for subject bindings. Prefer namespace-scoped Roles over ClusterRoles. See the gke-platform-security skill for full RBAC hardening guidance.
3. Resource Quotas
Prevent any single team from consuming all cluster resources:
apiVersion: v1kind: ResourceQuotametadata:name: team-a-quotanamespace: team-aspec:hard:requests.cpu: "10"requests.memory: "20Gi"limits.cpu: "20"limits.memory: "40Gi"pods: "50"services: "10"persistentvolumeclaims: "10"
4. LimitRanges
Set default and maximum resource constraints per container:
apiVersion: v1kind: LimitRangemetadata:name: team-a-limitsnamespace: team-aspec:limits:- type: Containerdefault:cpu: "500m"memory: "512Mi"defaultRequest:cpu: "100m"memory: "128Mi"max:cpu: "4"memory: "8Gi"
[!IMPORTANT] Mandatory Defaults: When definingminormaxlimits in aLimitRange, you must also define correspondingdefaultanddefaultRequestvalues. If you set aminormaxwithout defaults, any poddeployed without explicit resource requests/limits will be rejected by theadmission controller.
5. Network Isolation
Apply default-deny per namespace (see the gke-workload-security skill), then allow intra-team traffic:
# Allow same-namespace pods to talk + DNSapiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata:name: allow-same-namespacenamespace: team-aspec:podSelector: {}ingress:- from:- podSelector: {}egress:- to:- podSelector: {}- to: # Allow DNS- namespaceSelector: {}podSelector:matchLabels:k8s-app: kube-dnsports:- protocol: UDPport: 53
Cost Allocation
Labels for Cost Attribution
Label namespaces for billing in their manifests, proposed as a pull request through submit-suggestion: for example cost-center: engineering on team-a and cost-center: data-science on team-b.
GKE Cost Allocation
Enable GKE cost allocation to break down costs by namespace and label. It is a cluster setting (spec.costManagementConfig.enabled), changed as Config Connector YAML on the cluster's ContainerCluster through gcp-config-connector.
View in Cloud Billing > GKE Cost Allocation.