10 Essential kubectl Commands Every Linux Sysadmin Should Know
In this article, use 10 kubectl commands on Linux to inspect pods, read logs, roll back deployments, and scale apps on a Kubernetes cluster.
β Ravi Saive
When a service goes down at 2 a.m., you don't want to dig through documentation. You just need the right commands to find what broke and fix it fast.
Here are 10 essential kubectl commands for checking contexts, viewing logs, rolling back deployments, and scaling workloads.
Most day-to-day Kubernetes administration is done with kubectl, the command-line tool used to communicate with the Kubernetes API server, which handles the requests you send to the cluster and returns the information you need.
We selected these 10 commands because they cover many of the tasks you will perform regularly. Most of them are safe to run while investigating a problem, and the information they return usually helps you decide what to check or do next.
Before You Start
To follow along with the examples, this guide assumes you already have:
- A running Kubernetes cluster with
kubectlinstalled on your workstation. - A basic Deployment named
webrunning twonginxpods. (If you're new to Kubernetes, just think of a pod as a lightweight wrapper around one or more running containers, similar to how you might check a running systemd service or a Docker container on a standard Linux box.) - A
kubectlclient version that is within one minor version (older or newer) of your cluster's version to avoid compatibility quirks.