Created
January 10, 2025 05:57
-
-
Save djstein/e528dbbcb18540b35b0541a0df54ce32 to your computer and use it in GitHub Desktop.
get into the first pod of a type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# fish version | |
set -gx POD_NAME (kubectl get pods -n <namespace> --output json | jq -r -c '.items[].metadata | select(.name | contains("some name"))'.name | grep -v "excluded value" | grep -m 1 "some name") | |
kubectl exec -it {$POD_NAME} -n <namespace> -- /bin/bash | |
# for celery but not celery beat | |
set -gx POD_NAME (kubectl get pods -n backend-dev --output json | jq -r -c '.items[].metadata | select(.name | contains("celery"))'.name | grep -v "beat" | grep -m 1 "celery") | |
# bash version | |
POD_NAME=$(kubectl get pods -n backend-dev --output json | jq -r -c '.items[].metadata | select(.name | contains("celery"))'.name | grep -v "beat" | grep -m 1 "celery") | |
kubectl exec -it -n backend-dev ${POD_NAME} -- /bin/bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment