Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Kubernetes/windows/debug/networkmonitor/networkhealth.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1242,4 +1242,4 @@ Remove-Variable -name BASE_DIRECTORY -Scope Global
if ($MODE -ne [Mode]::HtmlOnly) {
Remove-Variable -name EVENT_SOURCE_NAME -Scope Global
Remove-Variable -name LOG_NAME -Scope Global
}
}
37 changes: 37 additions & 0 deletions Kubernetes/windows/debug/networkmonitor/networkhealthlocal.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: networkhealth
labels:
app: networkhealth
spec:
selector:
matchLabels:
name: networkhealth
template:
metadata:
labels:
name: networkhealth
spec:
securityContext:
windowsOptions:
hostProcess: true
runAsUserName: "NT AUTHORITY\\SYSTEM"
hostNetwork: true
containers:
- name: networkhealth
image: mcr.microsoft.com/windows/servercore:1809
args:
- powershell.exe
- -Command
- "$i = 1 ; $fileHash = \"00D231F41DBB11FAF13319124CAABE73806F0E5857068E1681A9ED1ECD2B2655\" ; While($i -le 300) { Start-Sleep -Seconds 2 ; Write-Host \"Iteration : $i\" ; if((Test-Path c:\\k\\debug\\networkhealth.ps1) -And ((Get-FileHash C:\\k\\debug\\networkhealth.ps1).Hash -Eq $fileHash) ){ Write-Host \"Networkhealthscript found.\" ; break ; } $i++ ; } c:\\k\\debug\\networkhealth.ps1 -OutputMode stdout; start-sleep 3600;"
imagePullPolicy: IfNotPresent
volumeMounts:
- name: kube-path
mountPath: C:\k
volumes:
- name: kube-path
hostPath:
path: C:\k
nodeSelector:
kubernetes.azure.com/os-sku: Windows2019
44 changes: 44 additions & 0 deletions Kubernetes/windows/debug/networkmonitor/startnetworkhealth.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

function WaitForDaemonsetToBeReady {
param (
[parameter(Mandatory = $true)] [string] $dsName
)
Write-Host "Checking status of daemonset $dsName ..."
$i = 0
$maxWait = 300

while($i -le $maxWait)
{
$status = (kubectl get ds $dsName -o json | ConvertFrom-Json).status
if($status.currentNumberScheduled -eq $status.desiredNumberScheduled)
{
Write-Host "Deamonset $dsName is ready ..."
return $true
}
Write-Host "Deamonset $dsName is not yet ready. Scheduled Pods : $status.currentNumberScheduled , Desired Pods : $status.desiredNumberScheduled ..."
Start-Sleep -Seconds 2
$i++
}

Write-Host "Creating $dsName daemonset failed. Scheduled Pods : $status.currentNumberScheduled , Desired Pods : $status.desiredNumberScheduled . Exiting..."
return $false
}

Write-Host "Deleting networkhealth daemonset if anything running..."
kubectl delete -f .\networkhealthlocal.yaml
Write-Host "Creating hetworkhealth daemonset to run script..."
kubectl create -f .\networkhealthlocal.yaml
$nwHlthPodStatus = WaitForDaemonsetToBeReady("networkhealth")
if(!$nwHlthPodStatus) {
return
}
Start-Sleep -Seconds 5
$nwHlthPods = kubectl get pods --no-headers -o custom-columns=":metadata.name" | findstr "networkhealth"
Write-Host "Networkhealth Pods : $nwHlthPods"
foreach($pod in $nwHlthPods)
{
Write-Host "Copying networkhealth script to hpc pod : $pod ..."
kubectl cp .\networkhealth.ps1 $pod`:C:\k\debug\networkhealth.ps1
Write-Host "Copying networkhealth script to hpc pod : $pod completed"
}
Write-Host "Creating networkhealth daemonset completed..."