Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kubectl tools #40

Open
delgadom opened this issue Aug 4, 2019 · 0 comments
Open

kubectl tools #40

delgadom opened this issue Aug 4, 2019 · 0 comments

Comments

@delgadom
Copy link
Member

delgadom commented Aug 4, 2019

Not sure exactly where these should go. But here are some useful kubectl templates

Interacting directly with pods

Find a (or one of several) named directory(ies) on all pods:

Calls python to search for directories on all pods matching a search criteria

kubectl -n NAMESPACE get pods | grep SEARCH_CRITERIA | awk '{ print $1 }' | xargs -I@ kubectl exec -n NAMESPACE @ -- /opt/conda/envs/worker/bin/python -c 'import sys; import os; matches=[f for f in os.listdir("PATH_TO_SEARCH_DIR") if f in [DIRNAME_OR_LIST_OF_DIRNAMES]]; print((str(sys.argv[1]) + ": " +  str(matches) + "\n") if len(matches) > 0 else "", end="");' @

For example, this finds specific geoclaw run directories on test-hub pods matching the pattern "dask-delgadom*":

kubectl -n test-hub get pods | grep dask-delgadom | awk '{ print $1 }' | xargs -I@ kubectl exec -n test-hub @ -- /opt/conda/envs/worker/bin/python -c 'import sys; import os; matches=[f for f in os.listdir("/") if f in ["gfdl5_rcp45_2007_2025_1825", "miroc5_rcp45_2007_2025_1083", "ccsm4_rcp85_2007_2025_626", "ccsm4_rcp85_2007_2025_1035", "mpi5_rcp45_2055_2065_668"]]; print((str(sys.argv[1]) + ": " +  str(matches) + "\n") if len(matches) > 0 else "", end="");' @

Managing pods

Delete "Succeeded" pods

kubectl -n NAMESPACE get pods | grep Completed | awk "{print $1}" | xargs kubectl -n NAMESPACE delete pods

for example on the main compute.rhg deployment:

kubectl -n rhodium-jupyter get pods | grep Completed | awk "{print $1}" | xargs kubectl -n rhodium-jupyter delete pods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant