machine_setup/ansible/roles/kubernetes/files/kshell

31 lines
717 B
Plaintext
Raw Normal View History

2022-12-02 04:38:21 +00:00
#!/usr/bin/env bash
#
set -euo pipefail
IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
: ${cpu:="500m"}
: ${memory:="2Gi"}
overrides=""
if [ ! -z "${highmem:-}" ]; then
overrides=$(jq --compact-output '.' <<EOF
{
"spec": {
"tolerations": [
{
"key": "dedicated",
"operator": "Equal",
"value": "background-highmem",
"effect": "NoSchedule"
}
],
"nodeSelector": {"dedicated": "background-highmem"}
}
}
EOF
)
fi
exec kubectl run --rm -i -t --image alpine:3.13 --overrides="$overrides" --requests "cpu=$cpu,memory=$memory" --limits "cpu=$cpu,memory=$memory" --pod-running-timeout 10m "tom-$(uuidgen | cut -d '-' -f 1)" -- /bin/sh "$@"