Add termination hook to the startup script - GCE Windows

This commit is contained in:
“Ibrahim 2021-08-12 00:54:19 +00:00
parent 1f8b1b84fb
commit aa9380e017
2 changed files with 9 additions and 0 deletions

View File

@ -205,5 +205,8 @@ catch {
Write-Host 'Exception caught in script:'
Write-Host $_.InvocationInfo.PositionMessage
Write-Host "Kubernetes Windows node setup failed: $($_.Exception.Message)"
# Make sure kubelet won't remain running in case any failure happened during the startup.
Write-Host "Cleaning up, Unregistering WorkerServices..."
Unregister-WorkerServices
exit 1
}

View File

@ -1286,6 +1286,12 @@ function Start-WorkerServices {
Log-Output "Kubernetes components started successfully"
}
# Stop and unregister both kubelet & kube-proxy services.
function Unregister-WorkerServices {
& sc.exe delete kube-proxy
& sc.exe delete kubelet
}
# Wait for kubelet and kube-proxy to be ready within 10s.
function WaitFor_KubeletAndKubeProxyReady {
$waited = 0