Get a DemoStart Free TrialSign In

Resources

5 min read

Last updated:

In the world of container orchestration, Kubernetes has become the de facto standard. Despite its simplicity in some respects, it has also introduced new levels of complexity in the deployment and management of distributed applications and services.

To assist you with understanding the most common kubectl commands & plugins, we've created a cheat sheet as a reference for operations engineers, software engineers, and cloud infrastructure managers who use Kubernetes primarily.

If you think anyone on your team would benefit from learning some of the most essential Kubernetes commands, please save the sheet below and share it with them.

Kubernetes cheat sheet (2)

You can share this via Twitter, LinkedIn, and Reddit.

Using logs when troubleshooting your Kubernetes cluster and applications is vital. The Kubernetes cluster and applications maintain detailed logs of every event, which can be used to narrow down the root causes of failures.

Role Based Access Control - Plugins Description
rakkess Show an access matrix for k8s server resources
kubectl-who-can Display who has RBAC permissions to perform actions on different resources in Kubernetes
Storage - Plugins Description
kubectl-plugin-pvc For PVC operations, a simple kubectl binary plugin.
kubectl-dfi Images on Kubernetes nodes can be listed and shown by their disk resources.
kubectl-df-pv Allowing administrators to manage persistent volumes with a DF (disk-free)-like utility.
Exec - Plugins Description
kubectl-enter Exec into node via kubectl.
kubectl-cssh A kubectl plugin to ssh into Kubernetes nodes within separate tmux panes.
kubectl-iexec Kubectl plugin to interactively exec into a pod.
kubectl-ssh A kubectl plugin to ssh into a pod's node.
kubectl-kcn A script and kubectl plugin which makes it easier to ssh into nodes within your cluster.
kubectl-exec-all Kubectl plugin to execute a command in all running pods of a resource.
kubectl-nsenter Simple kubectl plugin to take pod name, SSH onto node and spawn an nsenter shell.
kvaps kubectl-ssh Tiny plugin for connecting to node in the cluster over SSH.
kubectl-warp Kubernetes CLI plugin for syncing and executing local files in Pod on Kubernetes.
kubectl-plugin-ssh-jump A kubectl plugin to SSH into Kubernetes nodes using a SSH jump host Pod.
kubectl-texec Attach to the pod matching the label with Tmux.
Linting - Plugins Description
kubectl-lint Performs linting.
kubectl-neat Improves the readability of Kubernetes' yaml and json output.
ksort Sort manifest files according to kind.
Debugging - Plugins Description
kubectl-debug Debug your pod by a new container with troubleshooting tools already installed.
kube-profefe Makes continuous profiling easier to perform in Kubernetes.
Debugging - Plugins Description
kubectl-sudo Run Kubernetes commands with the security privileges of another user.
outdated Find and report outdated images running in a Kubernetes cluster.
kubectl-kubesec Security risk analysis for Kubernetes resources.
Networking - Plugins Description
ksniff An easy way to sniff on Kubernetes pods with tcpdump and Wireshark.
kubectl-swiftnp A kubectl plugin that renders details about network policies.
kubectl-trace Using the kubectl networking command, you can schedule bpftrace programs on your Kubernetes cluster.
kubectl-capture A plugin for kubectl that triggers a Sysdig capture.
Pods Description (# Get commands with basic output)
kubectl get services # List all services in the namespace.
kubectl get pods --all-namespaces # List all pods in all namespaces.
kubectl get pods -0 wide # List all pods in the current namespace, with more details.
kubectl get deployment my-dep # List a particular deployment.
kubectl get pods # List all pods in the namespace.
kubectl get pod my-pod -o yaml # Get a pod's YAML.
Deleting Resource Description
kubectl delete -f ./pod.json # Delete a pod using the type and name specified in pod.json.
kubectl delete pod unwanted -now # Delete a pod with no grace period.
kubectl delete pod, service baz foo # Delete pods and services with same names "baz" and "foo".
kubectl delete pods,services -l name=myLabel # Delete pods and services with label name=myLabel.
kubectl -n my-ns delete pod, svc -all # Delete all pods and services in namespace my-ns.
kubectl get pods -n mynamespace -o no-headers=true | awk '/pattern1 pattern2/{print$1}' | xargs kubectl delete -n mynamespace pod
Namespace Switching Description Additional Info
kubectx Switch faster between clusters and namespaces in Kubectl. Context/Namespace Switching
kubectl-ns Simple kubectl plugin to display/switch namespaces. Context/Namespace Switching
kubectl-use Plugin for simple switch kubernetes contexts and namespaces. Context/Namespace Switching
kubectl-switch Kubernetes multi-cluster command-line management tool. Context/Namespace Switching
caas-one kubectl-switch Kubernetes multi-cluster command-line management tool. Context/Namespace Switching
juanvallejo kubectl-ns Kubernetes multi-cluster command-line management tool. Context/Namespace Switching
km EKS MFA kubeconfig management tool. Context/Namespace Switching
Resource CRUDs Description Additional Info
ketall Like kubectl get all, but get really all resources. Resource CRUDs
kubectl-grep Filter Kubernetes resources by matching their names. Resource CRUDs
kubectl-all Kubectl plugin to list all resources in given namespaces. Resource CRUDs
kubectl-watch Watches Kubernetes resources. Resource CRUDs
kubectl-custom-cols A kubectl plugin that helps you customize output columns. Resource CRUDs
kubepod Search pods faster in kubectl. Resource CRUDs
kubectl-resources Plugin to access kubernetes resources requests, limits, and usage. Resource CRUDs
kubectl-free Show various requested resources on Kubernetes nodes. Resource CRUDs
kubectl-match-name Regex matching for resource names. Resource CRUDs
kubectl-elksporter A simple Ruby-script to exports k8sresources. Resource CRUDs
Authentication Description Additional Info
kubelogin Kubectl plugin for Kubernetes OpenID Connect authentication (kubectl iidc-login). Authn/Authz
k8s-pixy-auth K8s plugin to authentication against an OIDC compatible issuer using PKCE (pixy) flow. Authn/Authz
kubectl-login Kubectl plugin for re-authenticate into OpenID Connect Provider via CLI. Authn/Authz
zjj2wry kubectl-logiw The kubectl plugin is used to login to the Kubernetes cluster by OIDC authentication. Authn/Authz
kubectl-pass Kubectl plugin for integration with pass (the standard UNIX password manager). Authn/Authz
Other Commands Description Additional Info
kubectl-open-svc-plugin Kubectl open-sec plugin makes services accessible via their ClusterIP from outside your cluster. Uncategorized
kubectl-doctor K8s cluster triangle plugin - scan your cluster for anomalies (brew doctor equivalent). Uncategorized
kubectl-view-serviceaccount-kubeconfig-plugin A kubectl plugin that shows a kubeconfig to access the apiserver with a specific service account. Uncategorized
unfork Kubectl plugin to find forked Helm Charts and other k8s resources and unfork them. Uncategorized
kubectl-config-merge A Kubectl plugin for merging multiple kubeconfig files, a cli-runtime example. Uncategorized
konfig Konfig helps to merge, split, or import kubeconfig files. Uncategorized
kubectlsafe Safe operations in kubectl with plugin kubectlsafe. Uncategorized
kubectl-rainbow Simple binary to colorize output. Uncategorized
kubectl-ansible A sensible dynamic inventory plugin for Kubernetes cluster nodes. Uncategorized
kubectl-config-cleanup A kubectl plugin for automatically cleaning up your kubeconfig. Uncategorized
kubectl-gitlab-bootstrap Quickly add a Kubernetes cluster to a GitLab project. Uncategorized
kubectl-captain Kubectl plugin for captain. Uncategorized
kubectl-preflight Preflight Checks and Support Bundles Framework for Kubernetes Applications. Uncategorized
kubectl-support-bundle Holds all scripts to create packages and manifest files required for publishing with virtual binary as a krew package for kubectl. Uncategorized
kubectl-virt-plugin A CLI tool providing you with status and configuration of Kubernetes cluster fleet. Uncategorized
kcf Kubernetes PreUpGrade (Checker). Uncategorized
kubepug Uncategorized Uncategorized

The Logit.io platform offers a 14-day free trial to give you a taste of launching compliant, horizontally scalable observability stacks for Kubernetes monitoring if you are considering a new observability solution.

Try learning something new by reading our posts about open source log aggregators or use cases for Elasticsearch if you enjoyed this cheat sheet covering the most useful Linux commands.

Get the latest elastic Stack & logging resources when you subscribe

© 2024 Logit.io Ltd, All rights reserved.