-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathDetectDuplicateIpAddress.yaml
More file actions
32 lines (32 loc) · 2.17 KB
/
DetectDuplicateIpAddress.yaml
File metadata and controls
32 lines (32 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: detect-dup-ip
labels:
app: detect-dup-ip
spec:
selector:
matchLabels:
name: detect-dup-ip
template:
metadata:
labels:
name: detect-dup-ip
spec:
securityContext:
windowsOptions:
hostProcess: true
runAsUserName: "NT AUTHORITY\\SYSTEM"
hostNetwork: true
containers:
- name: detect-dup-ip
image: mcr.microsoft.com/dotnet/framework/samples:aspnetapp
command:
- powershell.exe
- -command
- |
Write-Host "Detecting duplicate IP addresses on the node..."; $BaseDir = "c:\k\debug"; Write-Host "Trying to load HNS module..."; ipmo $BaseDir\hns.v2.psm1 -Force | Write-Host; $iter = 1; pktmon stop; Write-Host "Starting pktmon with trace level 6 for HNS"; pktmon start --trace -p Microsoft-Windows-Host-Network-Service -l 6 -f traces.etl -s 1024; while($true){ $ipAddresses = ((Get-HnsEndpoint).IpConfigurations).IpAddress; Write-Host "IP addresses on the node:"; foreach($ip in $ipAddresses){ Write-Host $ip }; Write-Host "Checking for duplicate IP addresses inside the loop..."; $duplicateIpAddr = $ipAddresses | Group-Object | Where-Object { $_.Count -gt 1 }; if($duplicateIpAddr.Count -gt 0){ break }; $iter++; Start-Sleep -Seconds 300 }; Write-Host "Duplicate IP addresses found on the node, Duplicate IP addresses are:"; foreach($ipGroup in $duplicateIpAddr){ Write-Host $ipGroup.Name }; Write-Host "Stopping pktmon..."; pktmon stop; Write-Host "Collecting Windows logs..."; $collectWindowsLogs = "$BaseDir\collect-windows-logs.ps1"; powershell $collectWindowsLogs | Write-Host; Write-Host "Collected Windows logs and trace are at $PWD"; while($true){ if ($iter -Eq 1) { Write-Host "The issue was detected in the first iteration and it may have happened already, and log rotation may have occurred." } else { Write-Host "Issue detected. Please download and review the collected Windows logs and also traces from the following path: $PWD\traces.etl" }; Start-Sleep -Seconds 3600 }
securityContext:
privileged: true
nodeSelector:
kubernetes.azure.com/os-sku: Windows2022