Initial commit

This commit is contained in:
2025-03-18 19:21:17 +01:00
commit 8303887c16
137 changed files with 4067 additions and 0 deletions

53
functions/kex.fish Normal file
View File

@@ -0,0 +1,53 @@
function kex
set -l context (kubectl config current-context)
set -l namespace apps
set -l pod ""
set -l command ""
set -l debug false
getopts $argv | while read -l key value
switch $key
case c
set context $value
case n
set namespace $value
case d
set debug $value
case _
if test -z "$pod"
set pod $value
continue
end
if test -n "$command"
set command "$command "
end
set command "$command$value"
end
end
if $debug == true
echo "Context : $context"
echo "Namespace : $namespace"
echo "Pod basename: $pod"
echo "Command : '$command'"
end
set podname (kubectl --context="$context" --namespace="$namespace" get pod -l app="$pod",instance=app -o name | shuf | head -1 | sed 's/^pod\///')
if test -z "$podname"
echo "Pod $pod not found in cluster $contexts $namespace namespace" >/dev/stderr
return 1
end
echo "Pod found : $podname"
if test -z "$command"
kubectl --context="$context" --namespace="$namespace" exec -ti "$podname" -- bash
else
kubectl --context="$context" --namespace="$namespace" exec -ti "$podname" -- bash -c "$command"
end
end