Skip to content

Instantly share code, notes, and snippets.

@wonderbeyond
Last active July 15, 2021 09:29
Show Gist options
  • Save wonderbeyond/3603eac290267d700bda1d3e96976b36 to your computer and use it in GitHub Desktop.
Save wonderbeyond/3603eac290267d700bda1d3e96976b36 to your computer and use it in GitHub Desktop.
k8s cheatsheet

Get running pod names

kubectl -n fission-function get pods --field-selector status.phase=Running -o name

Get all logs of specified pods

KEYWORD="poolmgr-python-default"
NS="fission-function"

log_pods () {
    PODS=$(kubectl -n "$NS" get pods --field-selector status.phase=Running -o name | grep "$KEYWORD")
    for p in $PODS
        do kubectl -n "$NS" logs $p --all-containers=true
    done
}

while true
    do log_pods;
    sleep 0.1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment