#!/usr/bin/env bash # set -euo pipefail IFS=$'\n\t' DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" ############## Setup ######################### function cleanup { for f in "${pods[@]}"; do log "Deleting $f" kubectl delete pod --force=true --grace-period=0 --namespace homepage "$f" done } pods=() for sig in EXIT; do trap "set +e; cleanup" "$sig" done function die { local status_code="$1" shift (>&2 echo "${@}") exit "$status_code" } function log { (>&2 echo "${@}") } ############## Program ######################### function main { local pod_name="tom-$(uuidgen | cut -d '-' -f 1)" pods+=("$pod_name") create_pod "$pod_name" kubectl wait pods -n homepage "$pod_name" --for condition=Ready --timeout=90s kubectl exec -i -t --namespace homepage "$pod_name" -- "${@}" } function create_pod { local pod_name="$1" kubectl apply -f - <