Created
January 25, 2019 16:01
-
-
Save rca/4d56f29d0bdefe169569490c4a93f0f2 to your computer and use it in GitHub Desktop.
Execute a command within a container running in Rancher k8s
This file contains hidden or 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 | |
set -e | |
set -x | |
SCRIPT_NAME=$(basename $0) | |
if [ -z "$4" ]; then | |
echo "${SCRIPT_NAME} <env> <namespace> <pod name> <command> [args]" 1>&2 | |
exit 1 | |
fi; | |
env=$1 | |
shift | |
namespace=$1 | |
shift | |
name=$1 | |
shift | |
pod=$(compose-flow -e ${env} rancher kubectl get pods --namespace ${namespace} | \ | |
grep "^${name}" | awk '{print $1}' | head -n1) | |
exec compose-flow -e ${env} rancher kubectl exec -ti --namespace ${namespace} $pod -- "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One thing this is missing is the ability to specify a specific container in a multi-container pod.