From e92d6e9bd095bf4d34569d777cad4a7a35cfc5d4 Mon Sep 17 00:00:00 2001 From: Rodolfo Carvalho Date: Wed, 10 Jun 2015 17:38:09 +0200 Subject: [PATCH] Simplify run-in-container script After changes in k8s and sti-base/sti-python some hacks can be removed. --- README.md | 20 +++++++------------- openshift/scripts/run-in-container.sh | 8 +++----- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 9b784332..cddb1d36 100644 --- a/README.md +++ b/README.md @@ -156,28 +156,22 @@ that make this script obsolete. Here is how you would run a command in a pod specified by label: -1. Inpect the output of the command below to find the name of a pod that matches a given label: +1. Inspect the output of the command below to find the name of a pod that matches a given label: oc get pods -l -2. Open a shell in the pod of your choice: +2. Open a shell in the pod of your choice. Because of how the images produced + with CentOS and RHEL work currently, we need to wrap commands with `bash` to + enable any Software Collections that may be used (done automatically inside + every bash shell). oc exec -p -it -- bash -3. Because of how `kubectl exec` and `oc exec` work right now, your current working directory is root (/). Change it to where your code lives: - - cd $HOME - -4. Because of how the images produced with CentOS and RHEL work currently, you need to manually enable any Software Collections you need to use: - - source scl_source enable python33 - -5. Finally, execute any command that you need and exit the shell. +3. Finally, execute any command that you need and exit the shell. Related GitHub issues: 1. https://github.com/GoogleCloudPlatform/kubernetes/issues/8876 -2. https://github.com/GoogleCloudPlatform/kubernetes/issues/7770 -3. https://github.com/openshift/origin/issues/2001 +2. https://github.com/openshift/origin/issues/2001 The wrapper script combines the steps above into one. You can use it like this: diff --git a/openshift/scripts/run-in-container.sh b/openshift/scripts/run-in-container.sh index 29c11f85..46fd80bb 100755 --- a/openshift/scripts/run-in-container.sh +++ b/openshift/scripts/run-in-container.sh @@ -9,9 +9,8 @@ # that make this script obsolete. # Related GitHub issues: -# [1] https://github.com/GoogleCloudPlatform/kubernetes/issues/8876 -# [2] https://github.com/GoogleCloudPlatform/kubernetes/issues/7770 -# [3] https://github.com/openshift/origin/issues/2001 +# - https://github.com/GoogleCloudPlatform/kubernetes/issues/8876 +# - https://github.com/openshift/origin/issues/2001 # Usage examples: @@ -39,5 +38,4 @@ POD_INSTANCE_NAME=`oc get pods \ -t "{{ with index .items ${POD_INDEX:-0} }}{{ .metadata.name }}{{ end }}"` # Run command in a container of the specified pod: -oc exec -p "$POD_INSTANCE_NAME" -it -- bash -c \ - "cd \$HOME && source scl_source enable python33 && ${@:-echo}" +oc exec -p "$POD_INSTANCE_NAME" -it -- bash -c "${@:-echo}"