Skip to content

Instantly share code, notes, and snippets.

@trevorlinton
Last active May 3, 2019 14:32
Show Gist options
  • Save trevorlinton/2ae85274db3f8b5bccf0d5f66f8a7f97 to your computer and use it in GitHub Desktop.
Save trevorlinton/2ae85274db3f8b5bccf0d5f66f8a7f97 to your computer and use it in GitHub Desktop.

Find all objects in a namespace (even custom resources)

function kubectlgetall {
  for i in $(kubectl api-resources --verbs=list --namespaced -o name | grep -v "events.events.k8s.io" | grep -v "events" | sort | uniq); do
    echo "Resource:" $i
    kubectl -n ${1} get --ignore-not-found ${i}
  done
}

Usage: kubectlgetall <namespace>

Opening a shell into a pod

kubectl exec <pod> --namespace <namespace> -i -t -- sh -il

Binding a port on a pod locally

kubectl port-forward <pod> <port>:<port>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment