Monitors, troubleshoots, and manages GKE TPU Dynamic Slices custom resources. Use when checking TPU slice lifecycle states, troubleshooting slice provisioning f
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-gke-ai-troubleshooting-tpu-dynamic-slices-monitoring-ad207f9f9e8c ,按照其中的说明把「gke-ai-troubleshooting-tpu-dynamic-slices-monitoring」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
Monitors the status of TPU Slice custom resources, troubleshoots provisioning failures, validates workload manifests on dynamic slices, and performs cleanups.
kubectl and gcloud CLIs configured to access the GKE cluster.Gather project, cluster, and slice context using cluster tools or the following parameters:
{project_id} (e.g., my-gcp-project){cluster_name} (e.g., tpu-cluster){location} (e.g., us-central1-a){slice_name} (e.g., test-slice){timestamp} (Optional; default to the last 30 minutes
window [T - 30m] to [T + 30m])When asked to inspect, troubleshoot, or check a slice status, immediately execute kubectl describe slice {slice_name} using available cluster tools to perform the inspection. Parse the resulting Status.Conditions output against the condition table below to diagnose the exact state and provide concrete recommendations.
Command:
kubectl describe slice {slice_name}
Analyze the Status.Conditions (especially Type: Ready and its Reason and
Status):
| Lifecycle State / Reason | Meaning | Recommended Action |
|---|---|---|
SliceNotCreated | GKE Slice Controller is initializing the slice and performing resource checks. | Wait a few minutes and re-check slice status. |
SliceCreationFailed | Prerequisites validation failed (e.g., selected nodes don't exist, nodes are already used by another slice, or the topology doesn't match the number of partitions). | Verify selected nodes exist, are unallocated, and topology matches partition count. |
ACTIVATING | GKE is actively forming and provisioning the TPU slice. | Monitor node provisioning. |
ACTIVE | The TPU slice is successfully formed and ready to host workloads. | Proceed to deploy or check workloads. |
ACTIVE_DEGRADED | The slice is usable, but one or more sub-blocks are degraded. | Monitor workload logs for interconnect or device errors. Check faulty node VMs. |
FAILED | GKE failed to form the TPU slice (e.g., selected nodes are not part of the same reservation block). | Ensure all selected nodes belong to the same reservation block. |
DEACTIVATING | The slice is dismantling (triggered by user deletion or a critical systemic failure). | Wait for dismantling to finish, or patch finalizers if stuck. |
INCOMPLETE | The terminal phase before the Slice CR is deleted from the cluster. | No action required; the resource will be removed shortly. |
When investigating slice creation or provisioning failures (SliceCreationFailed or FAILED), perform the following verification steps:
kubectl get nodes -l cloud.google.com/gke-tpu-slice, kubectl get slice -A).2x2 requires 4 nodes).Ensure workload manifests are configured correctly to target the dynamic slice.
Check that the Pod template contains the following annotations and selectors:
cloud.google.com/gke-tpu-slice-topology: "{topology}" (e.g.,
"4x4x4")cloud.google.com/gke-tpu-topology: "{topology}" (e.g., "4x4x4")cloud.google.com/gke-tpu-accelerator: "{accelerator_type}" (e.g.,
"tpu7x")cloud.google.com/gke-tpu-slice: "{slice_name}" (e.g., "test-slice")If deploying a multi-slice JobSet, verify:
alpha.jobset.sigs.k8s.io/exclusive-topology: cloud.google.com/gke-tpu-slicecloud.google.com/gke-tpu-slice-topology: "{topology}"cloud.google.com/gke-tpu-topology: "{topology}"cloud.google.com/gke-tpu-accelerator: "{accelerator_type}"cloud.google.com/gke-tpu-slice in the
nodeSelector; JobSet handles slice assignment automatically.If a slice is stuck in DEACTIVATING or deletion hangs indefinitely due to stuck finalizers:
Identify Cause: Explain that finalizers on the slice resource (metadata.finalizers) are preventing Kubernetes from completing resource deletion.
Propose Resolution: Propose removing finalizers from the metadata path (/metadata/finalizers) using a JSON patch operation:
kubectl patch slice {slice_name} --type json -p='[{"op": "remove", "path": "/metadata/finalizers"}]'
Provide Warning: Explicitly warn the user that removing finalizers bypasses standard controller dismantling and may leave underlying VM, network, or accelerator resources uncleaned or orphaned.
CRITICAL SAFETY MANDATE: The response MUST explicitly ask the user for confirmation (e.g. "Removing finalizers on /metadata/finalizers via JSON patch is a high-risk operation that may leave orphaned resources. Do you confirm you want to apply this patch to slice {slice_name}?") and pause for user confirmation before applying or executing the patch.
If dynamic slicing needs to be disabled:
Check for existing Slices:
kubectl get slice -A
Ensure all slices are deleted before disabling the controller.
Disable Slice Controller via gcloud:
gcloud container clusters update {cluster_name} \
--location={location} \
--no-enable-slice-controller
Delete the Slice CRD:
kubectl delete crd slices.accelerator.gke.io
Clean up Node Labels: Remove GKE TPU Slice labels from all nodes in the cluster:
kubectl label nodes --all cloud.google.com/gke-tpu-slice- cloud.google.com/gke-tpu-slice-topology-