Lazy commit on smitty.

This commit is contained in:
James Downie 2025-09-15 21:16:06 +10:00
parent 76a2b27f4b
commit 754d07fc32
2 changed files with 7 additions and 40 deletions

View File

@ -1,21 +1,7 @@
#!/bin/bash #!/bin/bash
NS="$1" NS="$1"
PODS="`mktemp`" DEPL="$2"
kubectl -n "$NS" --output=json get pods \ CMD="$3"
| jq -r .items[].metadata.name \ kubectl -n "$NS" exec "deployment/$DEPL" -ti -- "$CMD"
> "$PODS"
for POD in $(cat "$PODS"); do
CONTAINERS="`mktemp`"
kubectl -n "$NS" --output=json get pod "$POD" \
| jq -r .spec.containers[].name \
> "$CONTAINERS"
for CONTAINER in $(cat "$CONTAINERS"); do
# echo -e "$POD:\t$CONTAINER"
if [ "$CONTAINER" = "$2" ]; then
kubectl -n "$NS" exec -ti "$POD" -c "$CONTAINER" -- "$3"
fi
done
rm "$CONTAINERS"
done
rm "$PODS"

View File

@ -1,25 +1,6 @@
#!/bin/bash #!/bin/bash
NS="$1" NS="$1"
PODS="`mktemp`" DEPL="$2"
kubectl -n "$NS" --output=json get pods \ kubectl logs -n "$NS" "deployment/$DEPL"
| jq -r .items[].metadata.name \
> "$PODS"
for POD in $(cat "$PODS"); do
CONTAINERS="`mktemp`"
kubectl -n "$NS" --output=json get pod "$POD" \
| jq -r .spec.containers[].name \
> "$CONTAINERS"
for CONTAINER in $(cat "$CONTAINERS"); do
# echo -e "$POD:\t$CONTAINER"
if [ "$CONTAINER" = "$2" ]; then
if [ "$3" = "-f" ]; then
kubectl -n "$NS" logs -f "$POD" -c "$CONTAINER"
else
kubectl -n "$NS" logs "$POD" -c "$CONTAINER"
fi
fi
done
rm "$CONTAINERS"
done
rm "$PODS"