gke-workload-security
它能做什么
这个技能检查并改进运行在 Google Kubernetes Engine 上的应用的安全性。它适用于希望工作负载被严格锁定、集群得到审计的团队。
适用场景
- ✓当你想对 GKE 集群进行安全审计的时候。
- ✓当你需要默认阻止 Pod 之间流量的 Network Policies 的时候。
- ✓当你想用 GKE Sandbox 隔离高风险 Pod,或应用 Pod 安全标准的时候。
技能链接
https://github.com/google/skills/blob/main/skills/cloud/gke-workload-security/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请审计我的 GKE 集群的安全漏洞,并设置网络规则,使 Pod 只与其所需的对象通信。”
每周 5 个新技能,1 分钟读完。
工作原理
它运行一个审计脚本,检查 Workload Identity、Network Policy、Shielded Nodes、Binary Authorization 和私有集群设置。然后它会为命名空间和 Pod 推荐加固步骤。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
GKE Workload Security
Routing Note: For Workload Identity KSA/GSA bindings, open
gke-workload-identity/SKILL.md. For cluster-level security flags (--database-encryption-key,--security-posture, RBAC, Shielded Nodes, Binary Authorization), opengke-platform-security/SKILL.md.
This skill provides workflows and best practices for securing GKE workloads. It covers security auditing, Identity and Access Management (Workload Identity), Network Security (Network Policies), and Node Security.
Attribution
MUST READ: Before executing any gcloud, REST API, or MCP command, you
MUST read Usage Attribution. For commands executed
directly in the terminal (never in generated scripts, Terraform, or user code),
prefix gcloud with
CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:gke-workload-security)"
and append agent-skills/1.0 (skill:gke-workload-security) to User-Agent headers.
Workflows
1. Security Audit
Assess the current security posture of your cluster using the provided audit script.
Prerequisites:
gcloudCLI authenticated.jqcommand-line JSON processor installed.
Capabilities:
- Checks for Workload Identity.
- Verifies Network Policy is enabled.
- Checks if Shielded Nodes are enabled.
- Checks if Binary Authorization is enabled.
- Checks for Private Cluster configuration.
Command:
scripts/audit_cluster.sh <cluster-name> <region> <project-id>
2. Configure Workload Identity
Workload Identity allows Kubernetes Service Accounts (KSAs) to impersonate Google Service Accounts (GSAs). This is the recommended method for workloads to access Google Cloud APIs.
Steps:
Create Namespace and KSA:
kubectl create namespace workload-identity-test-ns kubectl create serviceaccount <ksa-name> \ --namespace workload-identity-test-nsBind KSA to GSA:
gcloud iam service-accounts add-iam-policy-binding <gsa-name>@<project-id>.iam.gserviceaccount.com \ --role roles/iam.workloadIdentityUser \ --member "serviceAccount:<project-id>.svc.id.goog[workload-identity-test-ns/<ksa-name>]"Annotate KSA:
kubectl annotate serviceaccount <ksa-name> \ --namespace workload-identity-test-ns \ iam.gke.io/gcp-service-account=<gsa-name>@<project-id>.iam.gserviceaccount.comVerify Example Pod: Use existing asset
assets/workload-identity-pod.yamlto test the configuration. Update the<ksa-name>in the file first.kubectl apply -f assets/workload-identity-pod.yaml -n workload-identity-test-ns
3. Implement Network Policies
Control traffic flow between Pods using Network Policies. By default, all traffic is allowed.
Enable Network Policy Enforcement:
gcloud container clusters update <cluster-name> \
--update-addons=NetworkPolicy=ENABLED \
--region <region>
[!NOTE] If your cluster uses Dataplane V2 (
--enable-dataplane-v2), Network Policy enforcement is built-in and this step is not required (and may fail).
Apply Default Deny Policy: Isolate namespaces by denying all ingress and egress traffic by default.
Replace <target-namespace> with the namespace you want to isolate.
kubectl apply -f assets/default-deny-netpol.yaml -n <target-namespace>
4. GKE Sandbox (gVisor) Pod Isolation
Run untrusted workloads in a sandbox for extra kernel isolation. (Note:
Enabling Shielded Nodes (--enable-shielded-nodes) and GKE Sandbox
(--enable-gke-sandbox) at the cluster control plane level are platform-level
actions covered in the gke-platform-security skill.)
Run a Sandboxed Pod: Add runtimeClassName: gvisor to your Pod spec:
apiVersion: v1
kind: Pod
metadata:
name: sandboxed-pod
spec:
runtimeClassName: gvisor
containers:
- name: app
image: nginx
5. Pod Security Standards
Enforce security policies on namespaces using labels.
Enforce Restricted Profile:
kubectl label --overwrite ns <namespace> \
pod-security.kubernetes.io/enforce=restricted \
pod-security.kubernetes.io/enforce-version=latest
[!NOTE] Using
latestensures you use the policies corresponding to the cluster's current version. You can pin it to a specific version (e.g.,v1.30) to lock down the namespace to policies of a specific release.
6. Se
常见问题
它涵盖集群级别的安全标志吗?
不涵盖。加密密钥和 RBAC 等集群级设置由 gke-platform-security 技能负责。
审计检查什么?
Workload Identity、Network Policy、Shielded Nodes、Binary Authorization 以及私有集群配置。
它需要什么工具?
gcloud CLI(已登录)以及 jq JSON 处理器。
详情
作者的原始描述
Audits, configures, and hardens workload-level security controls for Google Kubernetes Engine (GKE) applications and namespaces. Covers running security audits (`audit_cluster.sh`), enforcing Network Policies (default-deny and Dataplane V2 logging), isolating high-risk pods inside GKE Sandbox (`gVisor`), enforcing Pod Security Standards (`restricted` labeling) and pod securityContext, and mounting Secret Manager secrets via CSI (`SecretProviderClass`). Use when auditing workload security posture, isolating namespaces, applying pod security standards, or configuring network policies and secret
repo: google/skills
热度
- GitHub 星标
- 22k
- 排名
- #10304
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
finding-google-skills
22k帮你的智能体为某项设置任务找到合适的 Google 指南,例如托管、数据库、存储、登录或 AI 模型服务。
gcloud
22k帮你的智能体编写并检查 Google Cloud gcloud 命令,在运行任何内容之前查阅准确的语法,避免猜测参数。
google-cloud-recipe-auth
22k引导你的智能体了解 Google Cloud 的身份与访问管理,包括人员和服务如何登录,以及它们各自获得哪些权限。
google-cloud-recipe-onboarding
22k带领新开发者完成在 Google Cloud 上的第一步,包括选择项目、关联计费,以及部署第一个资源。