
Description
Verifies if a GKE or Kubernetes cluster is unused (no active compute, external exposure, or persistent data) before allowing deletion. Evaluates external exposure (LoadBalancer Service, Ingress, Gateway, MultiClusterIngress), persistent data (Bound PVC), and active compute (Running/Pending Pods in user namespaces) with low-overhead queries and fail-close timeouts.
SKILL.md
verify_unused
Use this skill to safety-check whether a GKE or Kubernetes cluster is active or unused before executing any cluster deletion commands (DeleteCluster, gcloud container clusters delete, or kubectl delete). This prevents accidental data loss, service interruption, and destruction of active environments.
Critical Rule
!IMPORTANTNEVER delete a GKE or Kubernetes cluster without running this verification skill first or verifying that
deletion_policy: VERIFY_UNUSEDis enforced. If this check returns[ACTIVE](exit code1) or fails due to network/server timeout ([FAIL-CLOSE], exit code2), you must block the deletion and prompt the user for explicit confirmation or intervention.
Safety Criteria
The safety verification evaluates three core heuristics. If any condition is met, deletion is blocked:
1. External Exposure
- Failure Condition: Presence of $\ge 1$
Serviceof typeLoadBalancer, OR anyIngress,Gateway(Gateway API), orMultiClusterIngressresource in any namespace. - Rationale: These resources indicate the cluster is actively serving (or configured to serve) ingress traffic. Deleting the cluster would cause an immediate service disruption for users or connected systems.
2. Persistent Data
- Failure Condition: Presence of $\ge 1$
PersistentVolumeClaim(PVC) in theBoundstate in any namespace. - Rationale: A Bound PVC indicates a persistent disk attached containing application state. Deleting the cluster could result in permanent, unrecoverable data loss.
3. Active Compute
- Failure Condition: Presence of $\ge 1$
PodinRunningorPendingstate in any user namespace (includesdefault, but excludes system namespaces likekube-systemor those prefixed withgke-). - Rationale: Running pods represent active compute, and Pending pods indicate a system attempting to schedule or scale work. System namespaces (
kube-system,gke-*) are excluded to avoid blocking deletion on cluster control-plane and addon overhead.
Performance Overhead & Reliability
To ensure checks add minimal overhead and operate safely under adverse network conditions:
- Low-Overhead Queries (Early Return): Because the policy only needs to confirm the existence of at least one active resource to block deletion, lists use standard chunk sizes (
--chunk-size=500) and the Python script terminates immediately upon finding the first offending resource. Note that passing--chunk-size=1withkubectl -o jsonis avoided becausekubectlsequentially loops through all pages before formatting output, which causes N sequential API requests. - Bounded Timeouts & Fail-Close Behavior: Synchronous API queries enforce explicit timeouts (
--request-timeout). If the checks do not complete within the timeout window or encounter API errors, the operation fails close (exit code2), blocking cluster deletion rather than assuming safety during control-plane latency or outages.
Usage Instructions
Step 1: Execute Verification Script
Execute the bundled safety verification script (scripts/verify_unused.py located inside this skill folder) against the target cluster:
python3 <skill_directory>/scripts/verify_unused.py --timeout 5.0
(Optional flags: --kubeconfig <path> or --context <name> can be passed to target specific environments).
Step 2: Interpret Output & Exit Codes
- Exit Code
0([UNUSED]):[UNUSED] Cluster is verified unused (no active compute, exposure, or persistent data). It is safe to proceed with cluster deletion.
Action: Safe to proceed with cluster deletion. - Exit Code
1([ACTIVE]):[ACTIVE] Cluster is currently in use! Deletion blocked. Active workloads/resources detected: - External Exposure: Service prod/frontend is of type LoadBalancer
Action: DO NOT delete the cluster. Stop immediately and present the detected active resources to the user. - Exit Code
2([FAIL-CLOSE]):[FAIL-CLOSE] Cluster safety check failed due to query error or timeout!
Action: DO NOT delete the cluster. Stop and report that verification failed close due to query error or API server timeout.
More skills from the gke-mcp repository
View all 25 skillscustom-golden-image-discovery
discover golden base images for GKE nodes
Jul 12DeploymentGoogle CloudKubernetesgke-ai-troubleshooting-handle-disruption-gpu-tpu
diagnose GPU and TPU workload disruptions
Jul 12DebuggingGoogle CloudKubernetesPerformancegke-ai-troubleshooting-jobset-interruption
diagnose GKE JobSet interruptions
Jul 12DebuggingGoogle CloudKubernetesObservabilitygke-ai-troubleshooting-skill-creation-guide
create GKE troubleshooting skill bundles
Jul 12DocumentationEngineeringGoogle CloudTechnical Writinggke-ai-troubleshooting-tpu-connection-failure-vbar-oom
diagnose GKE TPU connection failures
Jul 12DebuggingGoogle CloudKubernetesPerformancegke-app-onboarding
containerize and deploy apps to GKE
Jul 12ContainersDeploymentGoogle CloudKubernetes +1
More from Google Cloud
View publisherkb-search
search and extract local knowledge base documents
knowledge-catalog
Jul 12DocumentationKnowledge BaseSearchknowledge_catalog_discovery_agent
search and rank Knowledge Catalog data entries
knowledge-catalog
Jul 12Data AnalysisGoogle CloudKnowledge ManagementSearchfabric-builder
generate Terraform code for Google Cloud
cloud-foundation-fabric
Jul 12Google CloudInfrastructure as CodeTerraformfast-0-org-setup-prereqs
prepare prerequisites for FAST 0-org-setup
cloud-foundation-fabric
Jul 12Google CloudOperationsagent-aware-cli
design agent-aware command-line interfaces
vertex-ai-creative-studio
Jul 12CLIEngineeringGoogle Cloudbuild-mcp-genmedia
build and configure GenAI MCP servers
vertex-ai-creative-studio
Jul 12API DevelopmentGoogle CloudLLMMCP