Last active
March 13, 2024 18:51
-
-
Save GauntletWizard/f98a450de84129cef1f5c76d1af40528 to your computer and use it in GitHub Desktop.
Kubernetes tools
This file contains 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/bash | |
# Script to | |
# Relies on non-standard programs - ts(moreutils) | |
set -eux -o pipefail | |
labels="${1:-}" | |
if [[ $labels = "-h" ]] || [[ $labels = "--help" ]] | |
then | |
set +x | |
echo "Usage: $0 [labels]" | |
echo "See https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors" | |
echo "for information on how to craft a label selector" | |
exit 0 | |
fi | |
# Kill all our tails when we're done | |
trap 'kill $(jobs -p) $$' EXIT | |
pods="$(kubectl get pods -o name -l "${labels}")" | |
for pod in $pods | |
do | |
kubectl logs -f "$pod" | ts "%H:%M:%S $pod:"& | |
done | |
wait |
This file contains 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
{ | |
"apiVersion": "v1", | |
"kind": "Pod", | |
"metadata": { | |
"annotations": { | |
}, | |
"labels": { | |
# Fill Me | |
}, | |
"name": "FILLME", | |
"namespace": "default", | |
}, | |
"spec": { | |
/* | |
"affinity": { | |
"podAntiAffinity": { | |
"requiredDuringSchedulingIgnoredDuringExecution": [ | |
{ | |
"labelSelector": { | |
"matchExpressions": [ | |
{ | |
"key": "run", | |
"operator": "In", | |
"values": [ | |
"CHANGEME" | |
] | |
} | |
] | |
}, | |
"topologyKey": "kubernetes.io/hostname" | |
} | |
] | |
} | |
}, | |
*/ | |
"containers": [ | |
{ | |
"args": [ | |
"while true; do sleep 100000; done\n" | |
], | |
"command": [ | |
"bash", | |
"-c" | |
], | |
"image": "IMAGENAME", | |
"imagePullPolicy": "Always", | |
"name": "NAME", | |
"resources": {}, | |
"terminationMessagePath": "/dev/termination-log", | |
"terminationMessagePolicy": "File", | |
} | |
], | |
"restartPolicy": "Always", | |
"terminationGracePeriodSeconds": 30, | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment