Skip to content

Commit f466d92

Browse files
authored
Merge pull request kubernetes#104317 from ibabou/add_termination_hook_startup_script
Add termination hook to the startup script - GCE Windows
2 parents 2584a7c + aa9380e commit f466d92

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

cluster/gce/windows/configure.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,5 +205,8 @@ catch {
205205
Write-Host 'Exception caught in script:'
206206
Write-Host $_.InvocationInfo.PositionMessage
207207
Write-Host "Kubernetes Windows node setup failed: $($_.Exception.Message)"
208+
# Make sure kubelet won't remain running in case any failure happened during the startup.
209+
Write-Host "Cleaning up, Unregistering WorkerServices..."
210+
Unregister-WorkerServices
208211
exit 1
209212
}

cluster/gce/windows/k8s-node-setup.psm1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,12 @@ function Start-WorkerServices {
12861286
Log-Output "Kubernetes components started successfully"
12871287
}
12881288

1289+
# Stop and unregister both kubelet & kube-proxy services.
1290+
function Unregister-WorkerServices {
1291+
& sc.exe delete kube-proxy
1292+
& sc.exe delete kubelet
1293+
}
1294+
12891295
# Wait for kubelet and kube-proxy to be ready within 10s.
12901296
function WaitFor_KubeletAndKubeProxyReady {
12911297
$waited = 0

0 commit comments

Comments
 (0)