Open delgadom opened 5 years ago
Not sure exactly where these should go. But here are some useful kubectl templates
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*":
"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="");' @
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
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
For example, this finds specific geoclaw run directories on test-hub pods matching the pattern
"dask-delgadom*"
:Managing pods
Delete "Succeeded" pods
for example on the main compute.rhg deployment: