Skip to content

Instantly share code, notes, and snippets.

@Vladmel1234
Created September 11, 2022 05:37
Show Gist options
  • Save Vladmel1234/f218c49380038ae97c41f7a38486b4ef to your computer and use it in GitHub Desktop.
Save Vladmel1234/f218c49380038ae97c41f7a38486b4ef to your computer and use it in GitHub Desktop.
K8s debug script
NAMESPACE=my-namespace
cat <<EOF | kubectl apply -n $NAMESPACE -f -
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: debug
spec:
podSelector:
matchLabels:
app: debug
policyTypes:
- Egress
egress:
- {}
EOF
kubectl run -i --tty -n $NAMESPACE --rm debug -l app=debug --image=busybox --restart=Never -- sh
kubectl -n $NAMESPACE delete networkpolicy debug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment