File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -84,9 +84,8 @@ if [[ $# -gt 0 ]]; then
8484fi
8585
8686echo -e " \nConnecting...\nPod: ${POD} \nNamespace: ${NAMESPACE} \nUser: ${USERNAME} \nContainer: ${CONTAINER} \nCommand: $COMMAND \n"
87-
88- # Limits concurrent sessions (each session deploys a pod) to 2. It's not necessary, just a preference.
89- test " $( exec " ${KUBECTL} " get po " $( whoami| tr -dc ' [:alnum:]' ) -1" 2> /dev/null) " && container=" $( whoami| tr -dc ' [:alnum:]' ) -2" || container=" $( whoami| tr -dc ' [:alnum:]' ) -1"
87+ # $temp_container is the name of our temporary container which we use to connect behind the scenes. Will be cleaned up automatically.
88+ temp_container=" ssh-pod-${RANDOM} "
9089
9190# We want to mount the docker socket on the node of the pod we're exec'ing into.
9291NODENAME=$( ${KUBECTL} get pod " ${POD} " -o go-template=' {{.spec.nodeName}}' )
@@ -117,7 +116,7 @@ read -r -d '' OVERRIDES <<EOF || :
117116 "containers": [
118117 {
119118 "image": "docker",
120- "name": "'$container '",
119+ "name": "'$temp_container '",
121120 "stdin": true,
122121 "stdinOnce": true,
123122 "tty": true,
@@ -157,6 +156,6 @@ read -r -d '' OVERRIDES <<EOF || :
157156}
158157EOF
159158
160- trap ' $KUBECTL delete pod $container >/dev/null 2>&1 &' 0 1 2 3 15
159+ trap ' $KUBECTL delete pod $temp_container >/dev/null 2>&1 &' 0 1 2 3 15
161160
162- eval " $KUBECTL " run -it --restart=Never --image=docker --overrides=" '${OVERRIDES} '" " $container "
161+ eval " $KUBECTL " run -it --restart=Never --image=docker --overrides=" '${OVERRIDES} '" " $temp_container "
You can’t perform that action at this time.
0 commit comments