Skip to content

Commit 898ce65

Browse files
committed
fix: skip resource deletion in cleanup.ps1 when cluster is unreachable
When the Kind cluster is not reachable (e.g. failed deploy in CI), kubectl falls back to localhost:8080 and all delete commands fail with connection errors. Added a cluster-info connectivity check before resource deletion — if unreachable, skip straight to kind delete cluster since resources are removed with the cluster anyway.
1 parent ea50009 commit 898ce65

1 file changed

Lines changed: 26 additions & 17 deletions

File tree

‎examples/cloud-deployment/scripts/cleanup.ps1‎

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,28 +43,37 @@ if (-not $Force) {
4343
}
4444

4545
Write-Host ""
46-
Write-Host "Deleting A2A Agent..."
47-
kubectl delete -f "..\k8s\05-agent-deployment.yaml" --ignore-not-found=true
46+
Write-Host "Checking cluster connectivity..."
47+
$null = kubectl cluster-info 2>$null
48+
if ($LASTEXITCODE -eq 0) {
49+
Write-Host "✓ Cluster reachable, deleting resources..." -ForegroundColor Green
4850

49-
Write-Host ""
50-
Write-Host "Deleting ConfigMap..."
51-
kubectl delete -f "..\k8s\04-agent-configmap.yaml" --ignore-not-found=true
51+
Write-Host ""
52+
Write-Host "Deleting A2A Agent..."
53+
kubectl delete -f "..\k8s\05-agent-deployment.yaml" --ignore-not-found=true
5254

53-
Write-Host ""
54-
Write-Host "Deleting Kafka topic..."
55-
kubectl delete -f "..\k8s\03-kafka-topic.yaml" --ignore-not-found=true
55+
Write-Host ""
56+
Write-Host "Deleting ConfigMap..."
57+
kubectl delete -f "..\k8s\04-agent-configmap.yaml" --ignore-not-found=true
5658

57-
Write-Host ""
58-
Write-Host "Deleting Kafka..."
59-
kubectl delete -f "..\k8s\02-kafka.yaml" --ignore-not-found=true
59+
Write-Host ""
60+
Write-Host "Deleting Kafka topic..."
61+
kubectl delete -f "..\k8s\03-kafka-topic.yaml" --ignore-not-found=true
6062

61-
Write-Host ""
62-
Write-Host "Deleting PostgreSQL..."
63-
kubectl delete -f "..\k8s\01-postgres.yaml" --ignore-not-found=true
63+
Write-Host ""
64+
Write-Host "Deleting Kafka..."
65+
kubectl delete -f "..\k8s\02-kafka.yaml" --ignore-not-found=true
6466

65-
Write-Host ""
66-
Write-Host "Deleting namespace..."
67-
kubectl delete -f "..\k8s\00-namespace.yaml" --ignore-not-found=true
67+
Write-Host ""
68+
Write-Host "Deleting PostgreSQL..."
69+
kubectl delete -f "..\k8s\01-postgres.yaml" --ignore-not-found=true
70+
71+
Write-Host ""
72+
Write-Host "Deleting namespace..."
73+
kubectl delete -f "..\k8s\00-namespace.yaml" --ignore-not-found=true
74+
} else {
75+
Write-Host "⚠ Cluster not reachable, skipping resource deletion — resources will be removed with the cluster." -ForegroundColor Yellow
76+
}
6877

6978
Write-Host ""
7079
Write-Host "Deleting Kind cluster..."

0 commit comments

Comments
 (0)