From b65259e8e3cfaf75e4c14ea73f5c57cca25721f2 Mon Sep 17 00:00:00 2001 From: Madhan Raj Mookkandy Date: Mon, 18 Jun 2018 19:04:16 -0700 Subject: [PATCH] Fix for kubelet startup script when using azure cni --- parts/k8s/kuberneteswindowssetup.ps1 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/parts/k8s/kuberneteswindowssetup.ps1 b/parts/k8s/kuberneteswindowssetup.ps1 index 704d4da9c6..3392e50cc6 100644 --- a/parts/k8s/kuberneteswindowssetup.ps1 +++ b/parts/k8s/kuberneteswindowssetup.ps1 @@ -360,6 +360,24 @@ Write-Host "NetworkPlugin azure, starting kubelet." # Turn off Firewall to enable pods to talk to service endpoints. (Kubelet should eventually do this) netsh advfirewall set allprofiles state off +# startup the service + +`$hnsNetwork = Get-HnsNetwork | ? Type -EQ `$global:NetworkMode.ToLower() + +if (`$hnsNetwork) +{ + # Kubelet has been restarted with existing network. + # Cleanup all containers + docker ps -q | foreach {docker rm `$_ -f} + # cleanup network + Write-Host "Cleaning up old HNS network found" + Remove-HnsNetwork `$hnsNetwork + Start-Sleep 10 + `$cnijson = $global:KubeDir + "\azure-vnet.json*" + remove-item `$cnijson -ErrorAction SilentlyContinue +} + +Restart-Service Kubeproxy $KubeletCommandLine