Skip to content

Instantly share code, notes, and snippets.

@socketbox
Last active November 3, 2021 00:01
Show Gist options
  • Save socketbox/788e99488fa5fabf73902afeffa7f716 to your computer and use it in GitHub Desktop.
Save socketbox/788e99488fa5fabf73902afeffa7f716 to your computer and use it in GitHub Desktop.
Kubernetes debugging pod based on praqma/network-multitool image
#!/bin/zsh
set -euo pipefail
if [[ "$#" -ne 1 ]];
then
echo "Set the namespace by passing in a single argument"
fi
IMAGE="praqma/network-multitool:alpine-extra"
NAMESPACE=$1
echo "Namespace: $1"
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 -t -n $NAMESPACE --rm debug -l app=debug --image=$IMAGE --wait=true --restart=Never -- /bin/bash
kubectl delete netpol debug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment