此登錄庫釘選版本所收錄的最新上游作者日期。

gke-multitenancy

已同步 v1.0.0 授權: Apache-2.0 來源: google/skills/skills/cloud/gke-multitenancy 提交: 99c871e 收錄的最新變更:

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).

摘要

用途
協助規劃共用的 GKE 叢集,為不同團隊與環境設定適當的存取、資源、網路及成本界線。
使用時機
當多個團隊或開發環境需要共用 GKE 叢集,且必須選擇隔離界線、限制資源使用或歸屬成本時使用。
輸出結果
提供隔離模式建議,以及建立命名空間、RBAC、資源配額、LimitRange、網路政策、標籤與 GKE 成本分攤的範例指令和 Kubernetes 資訊清單。
上游變更(7 筆,最新收錄 2026-09-21)
becc4b8 Enforce semantic versioning (MAJOR.MINOR.PATCH) for skills. 在此技能的中繼資料中新增版本 1.0.0。
6aa329d Add gke-workload-security and rename gke-security to gke-platform-security 將 RBAC 參照更新為 `gke-platform-security`,並將網路隔離參照更新為 `gke-workload-security`。
c75b500 Restructure the YAML frontmatter in all SKILL.md files to nest the 'category' field under the 'metadata:' block. The 'category' field is used to organize the skills in the README.md 在技能的 frontmatter 中新增含有 `Containers` 類別的 `metadata` 區塊。
5d9d054 Refactor GKE basic skill into individual skills 將多租戶參考文件改為獨立技能,新增 frontmatter、更新安全性參照,並補充在設定 `min` 或 `max` 時必須設定 LimitRange 的 `default` 與 `defaultRequest` 的指引。
6f0b877 Nests cloud/ skills under a top level skills/ directory 將內容未變的多租戶參考文件移至頂層 `skills/` 目錄下。
9114a94 Flatten skill directories to work with multiple installation tools 將內容未變的參考文件從 `cloud/products/kubernetes-engine/gke-basics/references/gke-multitenancy.md` 移至 `cloud/gke-basics/references/gke-multitenancy.md`。
d3e3bab No public description 新增 GKE 多租戶參考文件,涵蓋命名空間隔離、RBAC、資源配額與 LimitRange、網路政策及成本分攤。
npx skills add "lettucebo/Skills#v2.2.0@gke-multitenancy" --full-depth

⚠ v2.2.0 發布後即可使用

GKE Multi-Tenancy

This reference covers enterprise multi-tenancy patterns on GKE, including namespace isolation, RBAC planning, resource quotas, and network segmentation.

MCP Tools: apply_k8s_manifest, get_k8s_resource, check_k8s_auth, describe_k8s_resource, delete_k8s_resource

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) : : :
Cluster-per-team Hard (full High Highest
: : isolation) : : :

Golden path recommendation: Start with namespace-per-team for cost efficiency. Escalate to stronger isolation only when compliance requires it.

Namespace Isolation Setup

1. Create Namespaces

kubectl create namespace team-a
kubectl create namespace team-b
kubectl label namespace team-a team=a
kubectl label namespace team-b team=b

2. RBAC Configuration

Principle: Grant minimal permissions per namespace. Never bind to system:authenticated.

# Namespace-scoped role for a team
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: team-a-developer
  namespace: team-a
rules:
- apiGroups: ["", "apps", "batch"]
  resources: ["pods", "deployments", "services", "configmaps", "jobs"]
  verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: team-a-developers
  namespace: team-a
subjects:
- kind: Group
  name: "team-a@example.com"  # Google Group
  apiGroup: rbac.authorization.k8s.io
roleRef:
  kind: Role
  name: team-a-developer
  apiGroup: 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: v1
kind: ResourceQuota
metadata:
  name: team-a-quota
  namespace: team-a
spec:
  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: v1
kind: LimitRange
metadata:
  name: team-a-limits
  namespace: team-a
spec:
  limits:
  - type: Container
    default:
      cpu: "500m"
      memory: "512Mi"
    defaultRequest:
      cpu: "100m"
      memory: "128Mi"
    max:
      cpu: "4"
      memory: "8Gi"

[!IMPORTANT] Mandatory Defaults: When defining min or max limits in a LimitRange, you must also define corresponding default and defaultRequest values. If you set a min or max without defaults, any pod deployed without explicit resource requests/limits will be rejected by the admission 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 + DNS
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-same-namespace
  namespace: team-a
spec:
  podSelector: {}
  ingress:
  - from:
    - podSelector: {}
  egress:
  - to:
    - podSelector: {}
  - to:  # Allow DNS
    - namespaceSelector: {}
      podSelector:
        matchLabels:
          k8s-app: kube-dns
    ports:
    - protocol: UDP
      port: 53

Cost Allocation

Labels for Cost Attribution

# Label namespaces for billing
kubectl label namespace team-a cost-center=engineering
kubectl label namespace team-b cost-center=data-science

GKE Cost Allocation

Enable GKE cost allocation to break down costs by namespace and label:

gcloud container clusters update <CLUSTER_NAME> --region <REGION> \
  --enable-cost-allocation

View in Cloud Billing > GKE Cost Allocation.

歷程

v1.0.0 mapping-added 99c871e