此注册表固定版本所收录的最新上游作者日期。

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