Last active
July 14, 2024 09:04
-
-
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)
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
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