Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Execute a command within a container running in Rancher k8s
#!/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 -- "$@"
@rca
Copy link
Author

rca commented Jan 25, 2019

One thing this is missing is the ability to specify a specific container in a multi-container pod.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment