#!/usr/bin/env bash set -aeou pipefail SCRIPT_VERSION="0.1" KUBECTL_RSH_IMAGE="${KUBECTL_RSH_IMAGE:-docker.io/library/busybox}" KUBECTL_RSH_IMAGE_TAG="${KUBECTL_RSH_IMAGE_TAG:-latest}" KUBECTL_RSH_NAMESPACE="${KUBECTL_RSH_NAMESPACE:-default}" KUBECTL_RSH_POD_CREATE_TIMEOUT="${KUBECTL_RSH_POD_CREATE_TIMEOUT:-3}" function print_help(){ cat << EOF Creates a pod on the node and executes a shell on that node. You need cluster admin rights and privileged pod execution rights Usage: kubectl rsh [nodeName] EOF } if [[ "$1" == "version" ]];then echo "$SCRIPT_VERSION" exit 0 fi if [[ "$1" == "--help" ]]; then print_help exit 0 fi NODE="$1" POD=$( kubectl create -n "$KUBECTL_RSH_NAMESPACE" -o name -f - </dev/null kubectl attach -n "$KUBECTL_RSH_NAMESPACE" -it "$POD"