본문으로 건너뛰기
Skillpedia
보안22k · #10301

gke-workload-identity

하는 일

이 스킬은 GKE 파드에서 실행되는 앱이 Google Cloud API에 로그인하지 못하는 이유를 찾습니다. 클러스터 안에서 권한이나 자격 증명 오류를 보는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓파드가 iam.serviceAccounts.getAccessToken 관련 403이나 permission denied 오류를 받을 때.
  • ✓파드가 기본 자격 증명을 찾지 못하거나 메타데이터 서버에 접근하지 못한다고 보고할 때.
  • ✓파드의 API 호출이 워크로드 ID 대신 노드의 기본 서비스 계정을 쓸 때.

스킬 링크

https://github.com/google/skills/blob/main/skills/cloud/gke-workload-identity/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/google/skills/blob/main/skills/cloud/gke-workload-identity/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“GKE 파드가 Cloud Storage를 호출할 때 permission denied 오류가 납니다. 이유를 찾고 해결 방법을 알려 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

클러스터와 노드 풀의 Workload Identity 설정, 그리고 Kubernetes 서비스 계정과 Google Cloud 서비스 계정의 연결을 확인합니다. 차이를 보고하고, 사람이 적용할 수 있는 수정 방법을 제안합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

GKE Workload Identity Federation Troubleshooting Skill

Use this skill to systematically diagnose why a Pod using Workload Identity Federation for GKE cannot authenticate to Google Cloud APIs. Typical symptoms:

  • HTTP/403 ... Permission 'iam.serviceAccounts.getAccessToken' denied on resource
  • google.auth.exceptions ... could not find default credentials / ComputeEngineCredentials cannot find the metadata server
  • API calls that unexpectedly use the node's default Compute Engine service account instead of the workload's identity.

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-identity)" and append agent-skills/1.0 (skill:gke-workload-identity) to User-Agent headers.

Read-only boundary

This skill is diagnostic and non-interactive. It only reads cluster, IAM, and logging state and proposes fixes as commands or GitOps manifest changes for a human to apply. It must never create or modify IAM bindings, KSA annotations, node pools, or clusters automatically. When evidence is missing or the fix requires a privileged change, summarize findings and hand off to a human (see Step 7).

Output discipline (apply to every conclusion)

When you report a diagnosis, always:

  1. Name the single most-likely root cause (not an open-ended list of possibilities).
  2. Explicitly rule out the other plausible causes, citing the evidence that excludes them. In particular, when the cause is node-pool configuration, state plainly that it is not a KSA annotation or IAM binding problem; when the cause is a missing role on a target resource, state that Workload Identity itself is not misconfigured.
  3. Give the exact remediation as a proposed change for a human — a concrete gcloud command (or GitOps manifest edit) with the real identifiers filled in — and never apply it automatically.

Diagnostic Workflow

Step 0: Context discovery & time window

Collect (from the user or the failing resource): PROJECT_ID, PROJECT_NUMBER, CLUSTER, cluster LOCATION, NAMESPACE, the KSA the Pod runs as, the node and node pool the Pod is scheduled on (used in Step 2), the target resource / API being called, and the exact error string. Define a time window around the first observed failure for log queries.

# Resolve the project number (used in the direct-binding principal identifier).
gcloud projects describe "{PROJECT_ID}" --format="value(projectNumber)"

# Confirm which KSA the workload runs as.
kubectl get pod "{pod_name}" -n "{namespace}" \
  -o jsonpath='{.spec.serviceAccountName}'

# Identify the node the Pod runs on, then the node pool that node belongs to
# (Step 2 checks the node pool's Workload Identity mode).
NODE=$(kubectl get pod "{pod_name}" -n "{namespace}" -o jsonpath='{.spec.nodeName}')
kubectl get node "$NODE" \
  -o jsonpath='{.metadata.labels.cloud\.google\.com/gke-nodepool}'

Step 1: Capture the exact error signature

Read the workload's own logs and the gke-metadata-server logs to classify the failure.

kubectl logs "{pod_name}" -n "{namespace}" --all-containers --prefix
kubectl describe pod "{pod_name}" -n "{namespace}"

Equivalent via Cloud Logging (preferred for historical events). Open it as a Logs Explorer deep link — URL-encode the query and append the project and time window: https://console.cloud.google.com/logs/query;query={URL_ENCODED_QUERY};timeRange={start}%2F{end}?project={project_id} (encode / as %2F, or use ;duration=PT1H for a rolling hour):

resource.type="k8s_container"
resource.labels.namespace_name="{namespace}"
resource.labels.pod_name="{pod_name}"
severity>=WARNING

Classify the signature:

  • iam.serviceAccounts.getAccessToken denied / HTTP/403 → the workload is using the GSA impersonation path. This is expected for the legacy setup, but if you intend to use direct binding, it means the KSA still carries a leftover iam.gke.io/gcp-service-account
자주 묻는 질문

IAM 바인딩을 바꾸나요?

아닙니다. 설정을 읽기만 하고, 사람이 적용할 수정안을 제안합니다.

어떤 오류를 다루나요?

토큰 접근 권한 거부, 기본 자격 증명 누락, 메타데이터 서버에 닿지 않는 오류를 다룹니다.

하지 않는 일은 무엇인가요?

IAM 바인딩, 서비스 계정 주석, 노드 풀, 클러스터를 만들거나 바꾸지 않습니다.

상세 정보

작성자의 원본 설명

Configures and diagnoses Workload Identity Federation for GKE authentication failures for Pods (403 "iam.serviceAccounts.getAccessToken" / permission denied, "could not find default credentials", or GKE metadata server unreachable) by verifying cluster and node-pool Workload Identity configuration, the Kubernetes ServiceAccount (KSA) to IAM binding (direct principal binding and legacy Google ServiceAccount impersonation), target-resource IAM roles, and gke-metadata-server health. Use when setting up KSA/GSA bindings (`roles/iam.workloadIdentityUser`, `iam.gke.io/gcp-service-account`) or when a

repo: google/skills

인기도

GitHub 스타
22k
순위
#10301
라이선스
Apache-2.0
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬