Last active
November 3, 2021 00:01
-
-
Save socketbox/788e99488fa5fabf73902afeffa7f716 to your computer and use it in GitHub Desktop.
Kubernetes debugging pod based on praqma/network-multitool image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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