Skip to main content

Synopsis

Generate Network Policies based on observed pod traffic.
kubectl kguardian gen networkpolicy [POD_NAME] [flags]
kubectl kguardian gen netpol [POD_NAME] [flags]  # Alias

Flags

FlagTypeDescriptionDefault
-n, --namespacestringNamespace of the podCurrent namespace
-a, --allboolGenerate for all pods in namespacefalse
-A, --all-namespacesboolGenerate for all pods cluster-widefalse
-t, --typestringPolicy type: kubernetes or ciliumkubernetes
--output-dirstringDirectory to save policiesnetwork-policies
--dry-runboolGenerate without applyingtrue

Examples

# Single pod
kubectl kguardian gen networkpolicy my-app -n prod --output-dir ./policies

# All pods in namespace
kubectl kguardian gen netpol --all -n staging --output-dir ./staging-policies

# Cilium policies cluster-wide
kubectl kguardian gen netpol -A --type cilium --output-dir ./cilium

# Generate and apply
kubectl kguardian gen netpol my-app --dry-run=false

See Generating Network Policies for detailed usage.