Skip to content

Instantly share code, notes, and snippets.

@cgustav
Last active July 14, 2024 09:04
Show Gist options
  • Save cgustav/dd36cd570db9c9bdc64aafd2678cb313 to your computer and use it in GitHub Desktop.
Save cgustav/dd36cd570db9c9bdc64aafd2678cb313 to your computer and use it in GitHub Desktop.
Run an ephemeral Pod with tons of networking tools in a specified kubernetes namespace (fish shell script)
function kubenet --description "Run an ephemeral Pod with tons of networking tools in a specified kubernetes namespace"
set -l namespace $argv[1]
if test -z "$namespace"
set namespace "default"
else
# Check if the namespace exists
if not kubectl get namespace $namespace &>/dev/null
echo "Namespace '$namespace' does not exist. Using 'default' namespace."
set namespace "default"
end
end
echo "Running Swiss Army Knife pod in namespace: $namespace"
kubectl run swiss-army-knife --namespace=$namespace \
--image=leodotcloud/swiss-army-knife:latest \
--labels="app=test,environment=debug" \
--rm -it --restart=Never --command -- /bin/bash
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment