Aks Network Capture
MicrosoftOfficialCreated by Microsoft
- Skill
- Workflow
- Cloud and DevOps
- MIT
- Low risk
- Has scripts
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
The aks-network-capture skill provides a governed procedure for collecting wire-level evidence from Azure Kubernetes Service (AKS) nodes. It is designed for scenarios requiring explicit packet capture after initial read-only diagnostics have been exhausted. The skill includes scripts for setting up capture configurations, executing the capture, generating test traffic, and retrieving the resulting data, alongside tools for collecting relevant Azure network metadata. It emphasizes strict authorization, target binding, and resource cleanup to ensure that captures are performed securely and within defined operational boundaries.
What it does
- Configures AKS nodes for packet capture using dedicated scripts.
- Executes bounded packet captures on specific nodes or pods.
- Collects Azure network configuration metadata for context.
- Generates test traffic to facilitate network troubleshooting.
- Retrieves capture artifacts and manages resource cleanup by run ID.
When to use it
- When you need to perform a packet capture on an AKS node.
- When you need to prove where network packets are being dropped.
- After read-only diagnostics have failed to resolve a connectivity issue.
- When you require wire-level evidence for network troubleshooting.
Advantages
- Provides a structured, repeatable process for network evidence collection.
- Includes built-in authorization and target binding steps to maintain security.
- Supports both Bash and PowerShell environments for flexibility.
- Ensures resource cleanup is tied to specific capture run IDs.
Usage examples
- “Capture packets on an AKS node to investigate a drop.”
- The agent initiates the capture workflow, starting with authorization and target binding, followed by the deployment of the capture configuration.
- “Run tcpdump on AKS to troubleshoot connectivity.”
- The agent guides you through the setup and execution of the packet capture scripts, ensuring the capture is bounded and authorized.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/microsoft/aks-network-capture/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip aks-network-capture.zip -d .agents/skills
Documentation by Microsoft
AKS Network Capture
Quick Reference
| Use | Requires | Safety |
|---|---|---|
| AKS pcap evidence | kubectl; az for Azure evidence | Bounded, pinned, least privilege |
When to Use This Skill
Use for explicit packet capture after read-only checks, not generic connectivity failures.
MCP Tools
Azure MCP's AKS area provides cluster and node-pool metadata, not Kubernetes command execution or packet capture.
Host Capability Gate
Before executing the workflow, confirm that the host permits the required
Bash or PowerShell execution, kubectl access to the bound cluster, az for
Azure evidence, access to the bundled scripts, and an approved artifact
destination. A governed Azure CLI tool alone does not establish that shell,
Kubernetes commands, or artifact operations are supported.
If a required capability is unavailable or prohibited, state that capture
execution is unavailable in this host. Analyze supplied, appropriately
redacted evidence or give the operator a target-bound collection/capture plan;
do not claim to have run it. Never route kubectl through Azure MCP, add an
unapproved execution path, or bypass host policy. Host support does not replace
the mutation and sensitive-data approvals below.
Run bundled scripts from the skill root only after this gate is satisfied.
Workflow/Steps
Check host capabilities, then complete authorization and target binding. Capture intent is not mutation consent. Stop for separate approval before any debug-container fallback.
Install Bash / PowerShell.
Capture nodes or pods with Bash / PowerShell.
Generate traffic if approved with Bash / PowerShell.
Retrieve the exact run with Bash / PowerShell.
Gather Azure evidence with Bash / PowerShell.
The ConfigMap runs run-capture.sh inside its pinned Linux image.
Error Handling
| Error | Action |
|---|---|
| Invalid input | Correct it before retrying. |
| Missing/stale ConfigMap | Run setup again. |
| Capture/retrieval failure | Inspect Job logs; missing evidence is not success. |
Files
- ATTRIBUTION.mdAdded by AutoGineer983 B
- LICENSELicence file added by AutoGineer1.1 KiB
- SKILL.md2.9 KiB
- references/capture-authorization.md1.4 KiB
- scripts/collect-azure-network-info.ps1Script7.9 KiB
- scripts/collect-azure-network-info.shScript7.0 KiB
- scripts/create-capture.ps1Script11.5 KiB
- scripts/create-capture.shScript12.4 KiB
- scripts/generate-test-traffic.ps1Script5.4 KiB
- scripts/generate-test-traffic.shScript6.1 KiB
- scripts/retrieve-captures.ps1Script9.4 KiB
- scripts/retrieve-captures.shScript8.1 KiB
- scripts/run-capture.shScript2.4 KiB
- scripts/setup-capture-configmap.ps1Script1.7 KiB
- scripts/setup-capture-configmap.shScript1.2 KiB
scripts/generate-test-traffic.ps1
# Generate bounded test traffic from a pod network namespace.
# Exit codes: 0 = success/help, 1 = execution failure, 2 = usage/argument error.
[CmdletBinding()]
param(
[string]$SourcePod,
[string]$Target,
[string]$Type = "http",
[string]$TargetPort,
[string]$SourceNamespace = "default",
[string]$Duration = "30s",
[string]$Interval = "1",
[switch]$AllowDebugContainer,
[switch]$Help
)
$DebugImage = "mcr.microsoft.com/cbl-mariner/busybox:2.0@sha256:e4fb4d51fc9b70d6cdc1ce66a0af02ab40554d2ca632e1d188fabc760e432fdd"
function Write-Usage {
@"
Usage: generate-test-traffic.ps1 -SourcePod <pod> -Target <host> [options]
Options:
-Type <type> http, https, dns, tcp, or ping (default: http)
-TargetPort <1-65535> Target port; required for tcp
-SourceNamespace <ns> Source namespace (default: default)
-Duration <Ns|Nm|Nh> Duration (default: 30s; maximum: 1h)
-Interval <seconds> Whole seconds between attempts (default: 1)
-AllowDebugContainer Use an ephemeral debug container after separate approval
"@
}
function Stop-Usage {
param([string]$Message)
[Console]::Error.WriteLine("Error: $Message")
[Console]::Error.WriteLine((Write-Usage))
exit 2
}
function Stop-Failure {
param([string]$Message)
[Console]::Error.WriteLine("Error: $Message")
exit 1
}
function Test-DnsSubdomain {
param([string]$Value)
return $Value.Length -le 253 -and
$Value -cmatch "^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$"
}
if ($Help) {
Write-Usage
exit 0
}
if ([string]::IsNullOrWhiteSpace($SourcePod)) {
Stop-Usage "-SourcePod is required"
}
if ([string]::IsNullOrWhiteSpace($Target)) {
Stop-Usage "-Target is required"
}
if (-not (Test-DnsSubdomain $SourcePod)) {
Stop-Usage "-SourcePod must be a DNS subdomain"
}
if (-not (Test-DnsSubdomain $SourceNamespace)) {
Stop-Usage "-SourceNamespace must be a DNS subdomain"
}
if ($Target.Length -gt 253 -or $Target -notmatch "^[A-Za-z0-9._:-]+$") {
Stop-Usage "-Target has invalid characters"
}
if ($Duration -cnotmatch "^([0-9]+)([smh])$") {
Stop-Usage "-Duration must look like 30s, 5m, or 1h"
}
$durationNumber = [int64]$Matches[1]
$durationSeconds = switch ($Matches[2]) {
"s" { $durationNumber }
"m" { $durationNumber * 60 }
"h" { $durationNumber * 3600 }
}
if ($durationSeconds -lt 1 -or $durationSeconds -gt 3600) {
Stop-Usage "-Duration must be between 1s and 1h"
}
if ($Interval -notmatch "^[0-9]+$") {
Stop-Usage "-Interval must be a non-negative integer"
}
switch -CaseSensitive ($Type) {
"dns" { if (-not $TargetPort) { $TargetPort = "53" } }
"https" { if (-not $TargetPort) { $TargetPort = "443" } }
"http" { if (-not $TargetPort) { $TargetPort = "80" } }
"tcp" { if (-not $TargetPort) { Stop-Usage "-TargetPort is required for tcp" } }
"ping" { $TargetPort = "0" }
default { Stop-Usage "-Type must be one of: http https dns tcp ping" }
}
if ($TargetPort -notmatch "^[0-9]+$") {
Stop-Usage "-TargetPort must be an integer"
}
$targetPortValue = [int64]$TargetPort
if ($Type -ne "ping" -and ($targetPortValue -lt 1 -or $targetPortValue -gt 65535)) {
Stop-Usage "-TargetPort must be between 1 and 65535"
}
if (-not (Get-Command kubectl -ErrorAction SilentlyContinue)) {
Stop-Failure "kubectl is not installed or not on PATH"
}
$PodScript = @'
set -u
target="$1"; port="$2"; duration="$3"; interval="$4"; traffic_type="$5"
case "$target" in *:*) url_host="[$target]";; *) url_host="$target";; esac
end=$(( $(date +%s) + duration ))
while [ "$(date +%s)" -lt "$end" ]; do
case "$traffic_type" in
http) wget -q -O /dev/null -T 5 "http://$url_host:$port/" && echo "http ok" || echo "http fail" ;;
https) wget -q -O /dev/null -T 5 --no-check-certificate "https://$url_host:$port/" && echo "https ok" || echo "https fail" ;;
dns) nslookup "$target" >/dev/null 2>&1 && echo "dns ok" || echo "dns fail" ;;
tcp) nc -z -w 5 "$target" "$port" && echo "tcp ok" || echo "tcp fail" ;;
ping) ping -c 1 -W 5 "$target" >/dev/null 2>&1 && echo "ping ok" || echo "ping fail" ;;
esac
[ "$interval" -eq 0 ] || sleep "$interval"
done
'@
Write-Output "Generating $Type traffic from $SourcePod to $Target for ${durationSeconds}s"
& kubectl exec -n $SourceNamespace $SourcePod -- sh -c "exit 0" 2>$null
$directExecAvailable = $LASTEXITCODE -eq 0
if ($directExecAvailable) {
& kubectl exec -n $SourceNamespace $SourcePod -- sh -c $PodScript _ `
$Target $targetPortValue $durationSeconds $Interval $Type
if ($LASTEXITCODE -ne 0) {
Stop-Failure "traffic generation failed in the source pod"
}
} else {
if (-not $AllowDebugContainer) {
Stop-Failure "direct pod exec is unavailable; obtain separate approval before retrying with -AllowDebugContainer"
}
$targetContainer = (& kubectl get pod -n $SourceNamespace $SourcePod `
-o 'jsonpath={.spec.containers[0].name}' 2>&1) -join "`n"
if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($targetContainer)) {
Stop-Failure "could not resolve the source pod container: $targetContainer"
}
& kubectl debug -n $SourceNamespace $SourcePod --image=$DebugImage `
--target=$($targetContainer.Trim()) -q -- sh -c $PodScript _ `
$Target $targetPortValue $durationSeconds $Interval $Type
if ($LASTEXITCODE -ne 0) {
Stop-Failure "traffic generation failed in the ephemeral debug container"
}
}
Write-Output "Traffic generation complete"
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs Node.js
Security
What our scanner noticed· Low risk
- Scripts that your agent may run
This skill includes scripts that your agent may run. Read them before you use it.
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- Microsoft
- Publisher
- Microsoft (Official)
- Source
- microsoft/skills · .github/plugins/aks-skills/skills/aks-network-capture · commit 0696600
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from .github/plugins/aks-skills/LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Microsoft or Microsoft.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download aks-network-capture.zip