Diagnoses GKE persistent-storage failures — volume attach/mount errors (Regional PD on optimized VMs, fsGroup mount timeouts), disk-performance and node storage
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-gke-storage-troubleshooting-30880d04ad9e ,按照其中的说明把「gke-storage-troubleshooting」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
Use this skill to systematically diagnose and resolve persistent-storage failures for workloads running on GKE — volume attach/mount errors, disk performance and node storage pressure, volume expansion, storage-related cluster/node-pool creation errors, and Cloud Storage FUSE memory issues. This skill operates non-interactively and enforces a read-only diagnostics boundary before proposing manifest or configuration corrections.
For routine storage provisioning and StorageClass/PVC authoring, use the
gke-storageskill instead. This skill focuses on failure diagnosis.
Parameter Extraction: Extract required context (project_id,
cluster_name, cluster_location, workload_name, workload_namespace,
pod_name, and the relevant pvc_name / pv_name / node_name)
non-interactively from the user prompt, active SETTINGS.md, or environment
defaults:
workload_namespace to default if omitted.kubectl config current-context or gcloud config get-value project).Cluster Credentials & Fallback Mode:
gcloud container clusters get-credentials {cluster_name} --location {cluster_location} --project {project_id}.kubectl / gcloud diagnostic
commands for the human operator to run.Gather the primary signals, then jump to the matching branch under Step 2 (Resolution) — you normally perform only the one branch that matches your diagnosis, not all of them.
Diagnostic Commands:
kubectl describe pod {pod_name} -n {workload_namespace}
kubectl get pvc,pv -n {workload_namespace}
kubectl get events -n {workload_namespace} --sort-by='.metadata.creationTimestamp'
kubectl describe node {node_name}
ContainerCreating with an attach/mount event → Volume
Attach & Mount Failures.PLEG is not healthy, or StoragePressureDetected
events → Disk Performance & Node Storage Pressure.Perform only the branch that matches your Step 1 diagnosis. These branches are mutually exclusive alternatives, not sequential steps.
Error 400: Cannot attach RePD to an optimized VM: Regional persistent
disks are restricted from being used with memory-optimized or
compute-optimized machine types.
Pods stay Pending / FailedScheduling after a node pool is moved to a
4th-generation (N4, N4A, N4D) machine series while the workload uses a
Persistent Disk StorageClass: N4/N4A/N4D machines do not support
Persistent Disk (they support Hyperdisk only), so a PVC bound to a pd-*
StorageClass cannot bind or schedule on those nodes. Events typically show
FailedScheduling with a volume node-affinity / topology conflict.
type: hyperdisk-balanced) for the Gen4 node pool.Hyperdisk Pods become unschedulable when a compute class falls back across VM generations (for example N4 priority, N2 fallback), or one StorageClass must serve mixed generations: a single static disk type in the StorageClass is not compatible with every machine series in the fallback list, so Pods cannot bind their volume on the fallback nodes.
Use automated disk type selection: set the StorageClass
parameters.type to dynamic with hyperdisk-type, pd-type, and
disk-type-preference, plus use-allowed-disk-topology: "true", so GKE
selects a compatible disk type per node and schedules Pods only onto
nodes that support it. One dynamic StorageClass can then span multiple
VM generations (requires the GKE versions noted in the docs).
Example dynamic StorageClass (GKE 1.35.3-gke.1290000+):
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: dynamic-volume
provisioner: pd.csi.storage.gke.io
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
parameters:
type: dynamic
pd-type: pd-balanced
hyperdisk-type: hyperdisk-balanced
# Preferred storage on nodes that support both PD and Hyperdisk;
# defaults to hyperdisk-type when omitted.
disk-type-preference: hyperdisk-type
# Best practice: schedule Pods only onto nodes that support the disk type.
use-allowed-disk-topology: "true"
Poor disk performance (symptoms such as task dockerd:... blocked for more than 300 seconds, PLEG is not healthy, or slow fs: disk usage
scans): the node boot disk is shared across the OS, container images, the
overlay filesystem, and disk-backed emptyDir volumes, and performance is
shared across all disks of the same type on the node.
emptyDir.Slow disk operations cause Pod creation failures: on affected node
versions (GKE 1.18–1.23 before the fixed patch releases), the k8s_node container-runtime logs show failed to reserve container name ... is reserved for ... (containerd issue #4604).
restartPolicy: Always or OnFailure in the PodSpec, and
increase boot-disk IOPS (larger disk or a faster disk type).StoragePressureDetected (high node storage pressure): node condition
StoragePressureRootFileSystem becomes True (for example, Disk /dev/nvme0n1 usage 89% exceeds threshold 85%), caused by excessive
emptyDir writes, large image pulls, or accumulating logs.
df -h on the affected node (focus on
/mnt/stateful_partition and ephemeral mounts).ephemeral-storage requests/limits, and
cleaning up unused files/images/logs.The selected machine type ... has a fixed number of local SSD(s): the
Local SSD count specified in EphemeralStorageLocalSsdConfig /
LocalNvmeSsdBlockConfig does not match the fixed count included with the
machine type.
count flag and
the correct value is configured automatically.Hyperdisk Storage Pools: cluster or node-pool creation fails with
ZONE_RESOURCE_POOL_EXHAUSTED (or similar Compute Engine resource errors):
the target zone lacks capacity for the requested Hyperdisk Balanced disks or
machine type.
Volume expansion must always be driven through the PersistentVolumeClaim. Editing the PersistentVolume directly can leave the container filesystem on the old size.
Keep the modified PersistentVolume object as it is.
Edit the PersistentVolumeClaim and set spec.resources.requests.storage
to a value higher than the current PersistentVolume size.
The kubelet then resizes the PV, PVC, and container filesystem automatically. Verify inside the Pod:
kubectl exec {pod_name} -n {workload_namespace} -- df -h
If Pods experience high memory use or OOM kills related to the Cloud Storage FUSE CSI driver:
Enable CPU/memory snapshots by configuring Cloud Profiler on the Cloud Storage FUSE CSI driver sidecar container.
Locate the OOM event in Cloud Logging, filtering by Pod:
jsonPayload.involvedObject.name="{pod_name}"
jsonPayload.involvedObject.kind="Pod"
OOMKilled
If the sidecar mounter or GCSFuse process OOMs, the Pod name is the workload
Pod's name; if the node driver OOMs, it is gcsfusecsi-node-*.
Extract the Pod UID (jsonPayload.involvedObject.uid) and timestamp, then
analyze the matching snapshot in Cloud Profiler using the
{pod_name}_{pod_uid} Service Version at the OOM timestamp.
Enforce the read-only diagnostics boundary: do not apply live mutations with
kubectl edit, kubectl patch, or kubectl apply. Instead, present the
corrected StorageClass, PersistentVolumeClaim, PodSpec (securityContext,
restartPolicy), or node-pool configuration as a reviewable patch to be applied
through the user's GitOps pipeline (for example, Config Sync, Argo CD, or Flux).
Mount stops responding due to the fsGroup setting: A Pod configured
with a securityContext.fsGroup on a volume that contains a large number
of files makes the kubelet recursively change ownership on every file,
which can time out the mount. The symptom is:
Unable to attach or mount volumes for pod; skipping pod ... timed out waiting for the condition
Confirm by checking the Pod logs for a Setting volume ownership for ... and fsGroup set entry, then apply one of:
securityContext.fsGroupChangePolicy: OnRootMismatch so ownership
is only changed when the top-level permissions do not match.fsGroup setting if it is not required.