Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: collect kubectl information in AKS Windows node log #3936

Merged
merged 2 commits into from
Dec 20, 2023
Merged
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
31 changes: 31 additions & 0 deletions staging/cse/windows/debug/collect-windows-logs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,37 @@ if (Test-Path $nvidiaInstallLogFolder) {
}
}

if ((Test-Path "c:\k\kubectl.exe") -and (Test-Path "c:\k\config")) {
try {
Write-Host "Collecting the information of the node and pods by kubectl"
function kubectl { c:\k\kubectl.exe --kubeconfig c:\k\config $args }

$testResult = kubectl version 2>&1
if ($LASTEXITCODE -ne 0) {
throw "Failed to run kubectl, result: $testResult"
}

kubectl get nodes -o wide > "$ENV:TEMP\kubectl-get-nodes.log"
$paths += "$ENV:TEMP\kubectl-get-nodes.log"

$nodeName = $env:COMPUTERNAME.ToLower()
kubectl describe node $nodeName > "$ENV:TEMP\kubectl-describe-nodes.log"
$paths += "$ENV:TEMP\kubectl-describe-nodes.log"

"kubectl describe all pods on $nodeName" > "$ENV:TEMP\kubectl-describe-pods.log"
$podsJson = & crictl.exe pods --output json | ConvertFrom-Json
foreach ($pod in $podsJson.items) {
$podName = $pod.metadata.name
$namespace = $pod.metadata.namespace
kubectl describe pod $podName -n $namespace >> "$ENV:TEMP\kubectl-describe-pods.log" # append
}
$paths += "$ENV:TEMP\kubectl-describe-pods.log"
}
catch {
Write-Host "Error: $_"
}
}

Write-Host "All logs collected: $paths"
Stop-Transcript

Expand Down