!kubectl cheet sheet

Kubectl is a command-line tool used to interact with Kubernetes clusters. It allows users to perform various operations such as deploying and managing applications, inspecting cluster resources, and accessing logs and debugging information.

Pods

List pods

kubectl get pods

List pods interactively

kubectl get pods --watch

Get full pod detail from the cluster store

kubectl get pods <pod-name> -o yaml

Formatted multi-line overview of an object

kubectl describe pods <pod-name>

Execute a command inside a pod

kubectl exec <pod-name> -- <command>

Open a shell inside a pod

kubectl -it <pod-name> -- sh
  • -itmakes the session interactive and connects STDIN and STDOUT to your own shell.

Context

View current kubectl context

kubectl config current-conext

Change context

kubectl config user-context another-context
Last modified July 21, 2024: update (e2ae86c)