Merge pull request #9 from rhcarvalho/simplify-run-in-container
Simplify run-in-container script
This commit is contained in:
commit
dbc2e6b57b
2 changed files with 10 additions and 18 deletions
20
README.md
20
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 <your-label-selector>
|
||||
|
||||
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 <pod-name> -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:
|
||||
|
|
|
@ -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}"
|
||||
|
|
Loading…
Reference in a new issue