Created
February 23, 2025 16:56
-
-
Save jphalip/68eb9819da31673c11cbec15807cd8ef to your computer and use it in GitHub Desktop.
Access a pod and execute a command
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
function pod_exec() { | |
POD_NAME_PATTERN=$1 | |
ARGS="${@:2}" | |
kubectl exec -it $(kubectl get pods --field-selector=status.phase=Running -o name | grep -m1 $POD_NAME_PATTERN | cut -d'/' -f 2) -- bash -c "$ARGS" | |
} | |
function pod_bash() { | |
pod_exec $1 bash | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment