What Is kubectl get in Kubernetes?

What Is kubectl get in Kubernetes?

A friendly, step-by-step guide to the most used command in Kubernetes: what it asks the cluster, how the answer travels back, how to read every column, how to filter and format the output, and how to use it safely.

Imagine you have just joined a team that runs an online shop on Kubernetes, a system that manages a group of computers as if they were one. On your first morning, someone messages you: “The checkout page is slow. Can you see if the payment pods are healthy?” You stare at your screen. The shop is running somewhere inside that cluster, invisible, like a city seen from the window of a plane. How do you look inside?

The answer, for almost every Kubernetes engineer in the world, begins with three words typed into a terminal: kubectl get. It is the command you will run more than any other. It is how you ask the cluster, “What do you have, and how is it doing?”

In this guide we will build the idea from zero, one small step at a time. Every new word is explained the first time it appears, and every big idea comes with an everyday comparison so it sticks. By the end you will know what the command does, what happens behind the scenes when you press Enter, how to read what comes back, and how to avoid the common traps.

1What Is kubectl get?

Before we look at the command, we need to meet five simple words: cluster, resource, API server, kubectl and namespace.

Word 1

Cluster

A cluster is a group of computers that work together as one big computer. Kubernetes is the software that manages this group and decides which computer runs which application.

Word 2

Resource

Everything Kubernetes keeps track of is stored as a resource: a pod (a running copy of your application), a service (a stable address), a node (one computer in the cluster), a secret, and dozens more. Each is a record with a name and details.

Word 3

API server

The API server is the front desk of the cluster. Every question and every instruction goes through it. It checks who you are, decides what you may do, and answers from the cluster’s records.

Word 4

kubectl

kubectl is the command-line tool you run on your own computer to talk to the API server. People pronounce it “cube-control” or “cube-cuttle”. Both are fine.

Word 5

Namespace

A namespace is a private workspace inside a cluster. Teams and applications are often kept in separate namespaces, like separate folders on a shared drive.

Word 6

Get

“Get” is a verb, an action word. It means “fetch and show me”. It reads information and never changes anything.

So what exactly is kubectl get?

kubectl get is a command that asks the cluster to list resources, or to show one particular resource, and prints the answer as a neat table in your terminal. For example, asking for pods lists every pod in your current namespace with its name, readiness, status, number of restarts and age.

The most important property of this command is that it is read-only. You can run it a thousand times and nothing in the cluster changes. That is why engineers use it constantly, even in production, as a safe first step to look around before deciding what to do.

Everyday analogy

Think of a hospital ward with a large whiteboard at the nurses’ station. The board lists every patient, their bed, and a short status: resting, awake, being discharged. Glancing at the board changes nothing about any patient. kubectl get is that glance at the board: a quick, safe, summary view of what the cluster is holding and how each thing is doing.

A short history

Google released Kubernetes as open source in 2014. From the beginning, it needed a command-line tool so that people could work with the cluster without writing programs. That tool grew into kubectl. Its “get” verb has been there from the earliest days, and it has stayed almost unchanged, because the idea is so simple and so useful: list the things, show their state.

Over the years, the output became richer. Today kubectl can print results in many shapes, filter them by labels, sort them, and even keep watching for changes live. We will meet all of these.

i
Remember this

kubectl get is your eyes on the cluster. It shows a summary. When you need deeper detail or reasons, you pair it with other commands, which we compare in Chapter 9.

2The Problem It Solves

A cluster is busy and mostly invisible. Applications start, stop and move around all day. Without a way to look, you would be working blind.

Why we need to look inside

A running cluster might hold hundreds of pods, dozens of services and many nodes. Pods are temporary. Kubernetes can stop one and start another in its place without asking you. The list of what exists right now is different from the list an hour ago.

So the very first questions in any situation are the same. What is running? Is it healthy? Where is it? How old is it? Did it restart? Is the new version rolled out? Every one of these begins with a “get”.

Other ways to look, and their limits

Web dashboards from cloud providers or add-on tools show pretty charts and clickable lists. They are wonderful for exploring, but they take time to open, often need extra setup and permissions, and cannot easily be used in scripts.

Monitoring systems such as Prometheus and Grafana collect numbers over time. They tell you how a system behaved yesterday and warn you of trouble. They are not the tool for the simple question “what exists right now?”.

Reading raw configuration files tells you what you asked for, not what is actually running. The two can differ, for example when a rollout has stalled halfway.

kubectl get answers the “right now” question in a second, from any terminal, in a form that both humans and scripts can read.

Way of lookingBest atWeakness
Web dashboardExploring visuallySlower, harder to script
Monitoring chartsHistory and alertsNot designed for quick live inventory
Configuration filesShowing what you intendedMay differ from what is really running
kubectl getLive state in seconds, easy to scriptA snapshot, with no history or graphs
Everyday analogy

Suppose you manage a warehouse. A monthly report tells you how sales went. A security camera archive tells you what happened last Tuesday. But if you want to know how many boxes are on shelf B right now, you simply walk over and look. kubectl get is walking over and looking.

flowchart LR
  Q["Question: what is running right now?"] --> D["Web dashboard"]
  Q --> M["Monitoring charts"]
  Q --> F["Configuration files"]
  Q --> G["kubectl get"]
  D --> R1["Good view, slow to open"]
  M --> R2["Good history, not live inventory"]
  F --> R3["Shows intent, not reality"]
  G --> R4["Live answer in seconds"]
    
Figure 1. Several ways to look at a cluster, and why get is the everyday first step.
0
changes made to the cluster by a get command
1
second is often all it takes to see the live state
Many
output shapes: tables, YAML, JSON, single values
!
Watch out

The list you see is only as complete as your current namespace and your current cluster. Many “missing pod” mysteries turn out to be a command run in the wrong place. We will return to this trap more than once.

3Core Concepts

The command looks short, but it has a clear anatomy. Learn these building blocks and you can read or write almost any variation.

The anatomy of the command

1

The tool: kubectl

The program you run. It reads your connection settings and talks to the cluster.

2

The verb: get

The action. It means fetch and display, with no changes made.

3

The resource type: for example pods

What kind of thing you want to see. You can use the full name, the plural, or a short nickname.

4

The optional name

If you add the name of one resource, you see only that one. If you leave it out, you see all of that type.

5

Optional flags

Extra switches that change where to look, what to filter and how to print the answer.

Resource types and their short names

Typing long names all day would be tiring, so many resource types have short nicknames. You can use either. The results are identical.

ResourceShort nameWhat it represents
podspoRunning copies of your application
servicessvcStable addresses in front of pods
deploymentsdeployManagers that keep a set number of pods running and handle updates
replicasetsrsThe helpers that deployments use to keep pod counts right
nodesnoThe computers in the cluster
namespacesnsPrivate workspaces inside the cluster
configmapscmSettings that applications read
persistentvolumeclaimspvcRequests for durable storage
ingressesingRules for web traffic entering the cluster
statefulsetsstsManagers for applications that need stable identity, such as databases
eventsevShort notes about what the cluster has done recently
Everyday analogy

Short names work like nicknames in a friend group. Everyone knows that “Bob” and “Robert” are the same person. Saying po or pods to Kubernetes means the same thing.

Namespaces: where to look

By default, kubectl get looks only in your current namespace, which is usually one called “default” unless you or your team changed it. To look in another, you add a namespace flag. To look in every namespace at once, you add the all-namespaces flag, usually written as a capital letter A. When a resource seems to be missing, this is the first thing to check.

Labels and selectors: filtering the crowd

A label is a small tag, a key and a value, attached to a resource, such as “app equals shop” or “tier equals frontend”. A selector is a filter that picks resources by their labels. With a label selector flag, kubectl get shows only the matching resources. This is how you narrow hundreds of pods down to the six you care about.

Output formats: how to see the answer

Default

Table

A compact, human-friendly table with a few useful columns. It is the everyday view.

Wide

Table with extras

The same table with additional columns, such as the pod’s internal address and the node it runs on.

YAML

Full record

The complete stored description of a resource in a readable text format. Ideal for studying every detail.

JSON

Full record for programs

The same complete record in a format that scripts and tools parse easily.

Name

Just names

Only the resource names, one per line. Handy for feeding into other commands.

Custom

Your own columns

You pick exactly which fields to show, either as columns or with a small path expression that pulls out a single value.

i
Good to know

Some resources are not inside any namespace at all. Nodes and namespaces themselves belong to the whole cluster, so namespace flags do not apply to them.

Contexts: which cluster am I talking to?

A context is a saved combination of three things: a cluster, a user identity, and an optional default namespace. Your kubeconfig can hold many contexts, one for each cluster you work with, such as a test cluster, a staging cluster and a production cluster. Exactly one is “current” at any time, and every command you type goes to that one. Switching context is like changing the channel on a television: the same remote control now shows a different programme.

Reading a full record: metadata, spec and status

When you ask for YAML or JSON output, you see the complete stored record. Almost every Kubernetes record has the same three parts, and knowing them makes any record readable.

Part 1

Metadata

The identity card: name, namespace, labels, creation time, and who or what owns it. This is where labels live.

Part 2

Spec

What was asked for: the desired state. For a pod, this includes the container image, the memory limits and the settings.

Part 3

Status

What is actually true right now, filled in by the cluster: the phase, the conditions, the computer it runs on. Comparing spec with status shows the gap the cluster is working to close.

The clue to remember is this: spec is the wish, status is the reality. Much of troubleshooting is reading both and asking why they differ.

4Architecture and Components

One short command touches several parts of the system. Let us meet each part, in the order your question meets it.

flowchart LR
  YOU["You type kubectl get pods"] --> KC["kubectl program on your computer"]
  CFG["kubeconfig file with cluster address and credentials"] --> KC
  KC -->|"HTTPS request"| API["Kubernetes API Server"]
  API --> AUTHN["Authentication: who are you?"]
  AUTHN --> AUTHZ["Authorization: may you list pods here?"]
  AUTHZ --> CACHE["Watch cache in API server memory"]
  CACHE -.-> ETCD["etcd: the cluster database"]
  CACHE --> RESP["Answer sent back as a table"]
  RESP --> OUT["Printed in your terminal"]
    
Figure 2. The path of one get request from your keyboard to the cluster’s records and back.

Piece by piece

The kubectl program runs on your own laptop or on a server you control. It does no thinking about the cluster itself. Its job is to translate your short command into a proper web request, send it, and then print the answer nicely.

The kubeconfig file is kubectl’s address book. It usually lives in a hidden folder in your home directory. It lists the clusters you can reach, the identities you can use, and a “context” that pairs one cluster with one identity and, optionally, a default namespace. The current context decides where every command goes.

On Amazon EKS, for example, a helper command from AWS writes the cluster entry into your kubeconfig, and kubectl asks the AWS command-line tool for a short-lived token each time, so your AWS identity becomes your Kubernetes identity.

The API server is the only door into the cluster’s records. It runs on the control plane, which is the group of computers that manage the cluster. It receives your request over an encrypted web connection.

Authentication is the check “who are you?”. It looks at your certificate or token. Authorization is the check “are you allowed to do this?”. Most clusters use role-based access control here, where roles list which actions on which resources are permitted.

The watch cache and etcd hold the truth. Etcd is a small, reliable database where Kubernetes stores every resource. To avoid overloading it, the API server keeps a copy in memory and answers many read requests from there.

Everyday analogy

Think of a library. You (kubectl) fill in a request slip at the desk. Your library card (the kubeconfig) shows who you are and which library branch you belong to. The librarian (the API server) checks your card and your borrowing rights. Then the librarian looks at the shelves, or at a quick-reference index kept behind the desk (the cache), and hands you a printed list. The main archive room (etcd) is rarely visited for simple lookups.

1
API server door for every request into the cluster
2
checks before any answer: who you are, what you may see
1
kubeconfig file decides which cluster receives your command
!
Common surprise

kubectl does not “log in” once and stay connected. Each command builds a fresh request from your kubeconfig. If your saved credentials expire, the very next command fails, even though nothing else changed.

5How kubectl get Works Internally

Here is what really happens in the second between pressing Enter and seeing the table.

sequenceDiagram
  participant U as You
  participant K as kubectl
  participant C as kubeconfig
  participant A as API Server
  participant E as etcd
  U->>K: kubectl get pods
  K->>C: Read cluster address and credentials
  K->>A: HTTPS request to list pods in the namespace
  A->>A: Check identity and permissions
  A->>E: Read the pod records if not cached
  E-->>A: Stored records
  A-->>K: Answer prepared as a table
  K-->>U: Print the table
    
Figure 3. The conversation behind a single get command.
1

Understand the words

kubectl works out which kind of resource you named. It keeps a small saved list of the resource types the cluster offers, so short names like po and svc can be turned into their full forms.

2

Build the web request

Under the hood a get is an ordinary HTTP GET request to a web address that names the resource type and the namespace. Asking for one resource by name fetches one record. Leaving the name out asks for a list.

3

Let the server choose the columns

kubectl asks the API server to prepare the answer as a table. The server decides which columns to show and how to word them. This is why even custom resource types added by third parties can show helpful columns.

4

Receive in pages

For long lists, kubectl asks for results in chunks, by default a few hundred at a time, and stitches them together. This protects the server from having to send a giant answer at once.

5

Print

kubectl formats the result as a table, YAML, JSON or whatever you requested, and shows it. For YAML and JSON it prints the full stored record instead of the summary table.

Getting one thing versus getting a list

Fetching one named resource is a direct lookup, which is fast and cheap. Listing every pod in a big cluster is a much larger request. The API server must find, filter and send potentially thousands of records. Label selectors and namespace flags shrink that work, because the server does the filtering before sending anything.

The watch mode

With the watch flag, kubectl prints the table once and then keeps the connection open. Whenever a matching resource changes, the API server pushes an update line, and kubectl prints it. You see a pod move from Pending to Running in real time without re-running the command. This works because the API server keeps a stream of change events that clients can subscribe to.

Everyday analogy

A normal get is like calling a restaurant to ask whether a table is free right now. The watch mode is like asking the host to keep the phone line open and shout the moment a table becomes available. You do not need to redial again and again.

i
Tip

The output you see is a snapshot of the moment the server answered. In a fast-changing cluster it may already be slightly out of date when it appears. For anything that must be exact, use the watch mode or repeat the command.

Why big clusters need care

In a small test cluster, listing everything is instant. In a large production cluster, the same request may ask the API server to gather and send tens of thousands of records. Every extra record costs memory on the server, network time, and printing time on your screen. Several people doing it at once can noticeably slow the cluster for everyone else.

Kubernetes protects itself in a few ways. Answers are sent in pages instead of one giant block. The server keeps popular data in memory, so it does not always need to bother the database. And a fairness system limits how much any one noisy client can take, so that critical internal components are never starved. You can help by asking narrower questions: pick a namespace, add a label selector, and ask only for the type you need.

Everyday analogy

Asking for the full list of every pod in a huge cluster is like asking a bank teller to read out every customer’s account number. Asking about one customer, in one branch, takes seconds. The teller, and the queue behind you, will thank you for the specific question.

Why custom resources fit so easily

Because the server prepares the table, anyone who adds a new resource type to Kubernetes can also tell the server which columns to show for it. That is why a certificate object from a certificate tool, or a database object from a database operator, shows sensible columns just like a built-in pod. The get command does not need to know about them in advance. It simply prints whatever table the server sends.

6Reading the Output and the Lifecycle

A table is only useful if you can read it. Let us decode the columns you will see most, and follow one pod through its life.

The pod table, column by column

Column

NAME

The unique name of the pod. Pods created by a deployment get a name made of the deployment name plus a random-looking suffix.

Column

READY

Shows two numbers such as 1/1 or 2/3. The first is how many containers in the pod are ready to serve. The second is how many the pod has in total.

Column

STATUS

A word describing the pod’s state right now, such as Running or Pending. This is the column engineers read first.

Column

RESTARTS

How many times Kubernetes had to restart a container in this pod. A growing number is a warning sign that something keeps crashing.

Column

AGE

How long ago the pod was created. A very young pod among old ones often means a recent restart or update.

Wide only

IP and NODE

The pod’s internal network address and the computer it runs on. They appear when you ask for the wide format.

What common statuses mean

StatusMeaningWhat to do next
PendingAccepted, but not yet running. It may be waiting for a computer with enough room, or for storage.Give it a moment, then look at its events for the reason
ContainerCreatingA computer was chosen and is preparing the containerWait; if stuck for long, check image download and storage mounts
RunningAt least one container is runningAlso check the READY column to see whether it is truly serving
CompletedA one-off task finished successfullyNothing; this is normal for jobs
CrashLoopBackOffThe container keeps starting and crashing, and Kubernetes waits longer between triesRead the container’s logs and last exit reason
ImagePullBackOff or ErrImagePullThe container image cannot be downloadedCheck the image name, tag and registry permissions
OOMKilledThe container used more memory than its limitRaise the memory limit or fix the memory use
TerminatingThe pod is being shut downWait; if stuck, look for programs that refuse to stop
EvictedThe computer ran short of resources and removed the podCheck node pressure and resource requests

One pod through its life

flowchart LR
  A["Pending"] --> B["ContainerCreating"]
  B --> C["Running"]
  C --> D["Terminating"]
  D --> E["Gone from the list"]
  C -->|"container crashes"| F["CrashLoopBackOff"]
  F -->|"restart after a delay"| C
    
Figure 4. The stages a pod passes through, as you would see them in the STATUS column.

If you run get with the watch flag while a new deployment rolls out, you can watch this story unfold: new pods appear as Pending, become ContainerCreating, then Running, while old pods change to Terminating and vanish. It is a live movie of your update.

Everyday analogy

The STATUS column is like the tracking page of a parcel delivery. “Order received”, “Out for delivery” and “Delivered” are the normal stages. “Delivery attempt failed” is the crash loop. The READY column is the doorbell: the parcel can be at your door and still not be handed over.

!
Watch out

“Running” does not mean “healthy”. A pod can be Running while READY shows 0/1, which means the container exists but is not yet passing its readiness check, so no traffic reaches it. Always read STATUS and READY together.

7Usage Patterns You Will Meet

Most day-to-day use of the command falls into a small set of patterns. Learn to recognise them and you can answer nearly any “what is going on?” question.

Look at one kind of resource

The plain form: get followed by the resource type. Use it for the first look at pods, services, deployments or nodes. It is the equivalent of glancing at the whiteboard.

Look at one named resource

Add the resource’s name after the type to see only that one. Combine it with YAML output to study its complete stored record, including fields the summary table hides.

Look everywhere

Use the all-namespaces flag to see resources from every workspace at once. This is the best way to find a mysterious pod when you do not know where it lives. In a big cluster, add a selector so the answer stays small.

Filter by label

The selector flag, written with a lowercase L, shows only resources whose labels match, for example everything belonging to one application. Many teams label every resource with the app name and the environment precisely so this filter works.

Filter by field

The field-selector flag filters by built-in fields such as a pod’s phase or the node it runs on. It answers questions like “which pods are on this computer?” or “which pods are not running?”. Only a limited set of fields can be filtered this way, so it is less flexible than labels.

See more columns

The wide output adds columns such as the node and the internal address. It is the best quick way to see where each pod landed. The show-labels flag adds a column listing every label on each resource.

Sort the result

The sort-by flag orders rows by any field, using a small path expression. A common use is sorting by creation time, so the newest resource appears last, or by restart count, so the unstable pods stand out.

Extract a single value

The JSONPath and custom-columns outputs pull out specific fields, for example only the container image of every pod. These are the tools for audits and reports, such as “which image versions are running across the cluster?”.

Keep watching

The watch flag keeps the command alive and prints each change as it happens. It is perfect during a rollout, a restart or a scaling event.

Prepare for scripting

The name output prints only names, one per line, and the no-headers flag removes the title row. Together they give clean lists that other commands can consume. For anything more structured, scripts should read JSON instead of parsing the human table.

Everyday analogy

These flags are the search filters on a shopping website. Plain get is “show all products”. Label selectors are “only brand X”. Field selectors are “only items in stock”. Sorting is “cheapest first”. Custom columns are choosing which details to display in the results grid.

!
Watch out

The word “all” is misleading. Asking for “all” resources shows only a common subset, such as pods, services, deployments and jobs. It leaves out many types, including config maps, secrets, ingresses and storage claims. Do not treat it as a complete inventory.

A worked investigation, told in words

Let us walk through a realistic morning. A colleague says the search page of the shop is failing. You open a terminal and first confirm you are pointed at the right cluster and the right namespace. Then you list the pods in the shop’s namespace, filtering by the search application’s label.

The table shows four pods. Three are Running and Ready. One shows CrashLoopBackOff with eleven restarts and an age of forty minutes. That single row already tells you a lot: the problem is not the whole application, only one pod, and it began around forty minutes ago, which might match a recent release.

Next you ask for the wide output and notice the failing pod is on a node that hosts nothing else from this application. You list the nodes and see that node has been up only an hour, a fresh computer added by the autoscaler. Now you have a theory: something about the new computer differs, perhaps a missing setting or a network rule.

Only now do you move to the deeper tools. You describe the failing pod, read its events, and read its logs. You find the application cannot reach its database from that computer. A quick message to the networking team, a fixed rule, and a new get with the watch flag shows the pod turning Running and Ready. Five minutes, four get commands, and you never guessed blindly.

i
The pattern to copy

Notice how each get result suggested the next question. Look wide, spot the odd one out, find what it has in common with the trouble, and only then reach for detailed tools. That rhythm is the real skill behind the command.

8Security and Safe Use

Because the command only reads, many beginners think it cannot cause harm. That is not quite true. Reading can leak secrets, and running commands against the wrong cluster can lead to costly mistakes.

Who is allowed to look?

Access to resources is governed by role-based access control. A role lists actions, called verbs, that are permitted on named resource types. Three verbs matter for reading. The get verb allows fetching one named resource. The list verb allows listing many. The watch verb allows the live streaming mode.

When you run the plain listing form, the cluster checks that you have the list permission. When you fetch one named resource, it checks the get permission. If a check fails, you see a “forbidden” message that names the missing permission. That message is helpful: it tells your administrator exactly what to grant.

Secrets

Secrets are only encoded

Listing secrets shows names, not values. But the YAML or JSON output of a secret shows its values in base64, which is a simple encoding, not encryption. Anyone who can read the record can decode it in seconds.

List power

List can be as strong as get

Permission to list secrets returns their full contents, so it is effectively permission to read every secret in scope. Grant it carefully.

Leaks

Environment values

Pod records can contain settings, addresses and sometimes passwords placed directly in environment variables. Full-record output reveals them.

Credentials

Protect the kubeconfig

The file holds the keys to your clusters. Keep it private, never commit it to source control, and prefer short-lived tokens issued by your identity system over long-lived static ones.

Records

Audit trails

Clusters can log who listed or read which resources and when. Turning this on helps you investigate leaks and unusual access.

Habits

Careful pasting

Do not paste full YAML into chats, tickets or screenshots without removing sensitive fields. The clipboard is a common source of leaks.

Everyday analogy

Reading is like being allowed into an office to look at files. You do not move anything, yet you could photograph a confidential page. So the visitor badge should open only the rooms the visitor truly needs, and the badge itself must not be left on a desk.

The wrong-cluster problem

The most common danger is not an attack but a slip. Your terminal remembers the last context you selected. If you switched to the production cluster this morning and forgot, a command you believed was going to a test cluster reaches production instead. With a read-only get, this only confuses you. With other verbs, it can be a disaster. Healthy habits include showing the current context in your shell prompt, using separate identities with different permissions for production, and checking the context before any risky command.

A short safety checklist

Grant read access by namespace, not cluster-wide, wherever possible. Keep secret-reading rights to a few people. Use short-lived credentials. Keep audit logging on. Show the active context in your prompt. Never share screenshots that contain full records. Keep kubectl updated to within one minor version of the cluster.

!
Read this twice

Base64 is not a lock. If your team believes “secrets are safe because they look scrambled”, correct that belief today. Safe handling depends on permissions, encryption at rest in the cluster, and careful output habits.

9Choosing the Right Command

The get command gives you the summary. Other commands give you reasons, logs and numbers. A good engineer knows which to reach for.

CommandQuestion it answersTypical use
kubectl getWhat exists, and what is its summary state?First look, lists, filters, live watching
kubectl describeWhy is it in this state? What happened recently?Detailed report with a list of recent events
kubectl logsWhat did the application itself say?Errors and messages from a container
kubectl topHow much processor and memory is it using?Quick resource checks, needs the metrics add-on
kubectl explainWhat does this field mean?Built-in documentation of resource fields
kubectl rollout statusHas the update finished?Waiting for a deployment in scripts and pipelines
kubectl waitHas it reached the condition I need?Pausing a script until something is ready
Everyday analogy

A doctor’s visit works in the same order. The nurse checks your temperature and pulse (get). The doctor then asks detailed questions and reads your history (describe). If needed, they check specific tests (logs and top). Jumping straight to the detailed tests without the quick check wastes time.

A sensible order for investigating a problem

1

Get

See what exists and read STATUS, READY and RESTARTS. This tells you whether there is a problem and roughly what kind.

2

Describe

Read the events at the bottom. They often name the exact cause: no room on any computer, image not found, storage not attached.

3

Logs

If the container started but misbehaves, read what the application printed before it failed.

4

Top

Check whether the application is starving for memory or processor time.

5

Get again

After a fix, run get with the watch flag to confirm the pod becomes healthy.

Choosing an output format

Human

Default table

Best when you just want to see and understand quickly.

Location

Wide table

Best when you need to know which computer each pod runs on.

Study

YAML

Best when you need to read every field of one resource and understand it.

Automation

JSON

Best when a program or a JSON tool will read the answer.

Reports

Custom columns

Best when you need a tidy table of exactly the fields you care about.

Pipelines

Names only

Best when passing a list of names to another command.

i
Tip for cloud users

On managed clusters such as Amazon EKS, run the provider’s helper to add the cluster to your kubeconfig, then confirm the current context before your first get. Nine out of ten early problems are “wrong context” or “expired credentials”, not Kubernetes faults.

10Advantages, Disadvantages and Trade-offs

No tool is perfect. A good engineer knows both what the command gives and what it costs.

Advantages

  • Fast, live answer to “what is running right now?”
  • Read-only, so safe to run at any time
  • Works from any terminal with no extra software on the cluster
  • Many output shapes for people and for programs
  • Filtering by label, field, namespace and sorting built in
  • Live watching of changes without repeating the command

Disadvantages

  • A snapshot only, with no history or trends
  • Summary columns hide details and reasons
  • Wrong context or namespace gives confusing results
  • Big listings can put load on the API server
  • Full-record output can expose secrets
  • Table text is meant for humans and is fragile to parse in scripts

The trade-offs behind the lists

Convenience versus load. Listing everything in every namespace is easy to type but expensive for the cluster. Selectors and namespaces cost you a few extra characters and save the server real work. In small clusters the difference is invisible. In clusters with tens of thousands of pods it is not.

Human view versus machine view. The default table is friendly, but its columns and wording can change between versions. Scripts that cut and slice that text can break. Reading JSON is more stable, at the price of a little more effort.

Breadth of access versus safety. Giving everyone permission to list everything makes life easy for engineers and also makes leaks easier. Namespace-scoped, read-only roles are slightly more work to manage but far safer.

Manual looking versus automation. Typing commands is quick for a person. For continuous checking, alerts and dashboards do the job better, and tools that manage the cluster from version control show desired versus actual state without anyone typing anything.

Look first, change second.

Get versus dashboards and GitOps tools

Many teams also use visual tools that show the cluster as a picture of boxes and arrows, and tools that keep the cluster in step with configuration stored in version control. These tools are helpful, and they do not replace the get command. A dashboard may be slow to reach, may be unavailable during an outage, or may hide the exact field you need. The command line works from anywhere you can reach the API server, even when everything else is broken.

Think of the command as the pocket torch you always carry. The dashboard is the floodlight on the building: brighter, but not always switched on when you need it. Skilled engineers use both, and they trust the torch most when the lights go out.

11Monitoring, Logging and Failure Handling

The get command is not a monitoring system, but it is the quickest health check you have. It also has its own failure messages that are worth understanding.

Get as a quick health check

Pods

Anything not Running?

Filter the pod list to those that are not Running or Completed. Any row that appears deserves a look.

Restarts

Climbing restart counts

Sort by restarts. A pod with dozens of restarts is unstable even if it shows Running at this second.

Nodes

Any node NotReady?

A node that is not Ready has lost contact with the control plane, and its pods may be rescheduled.

Rollouts

Deployment counts

Compare desired, updated and available replica counts. A gap means an update is stuck or still in progress.

Storage

Pending claims

Storage claims stuck in Pending explain many pods that never start.

Events

Recent warnings

Listing events sorted by time shows what the cluster did lately, such as failed scheduling or failed image pulls.

401
“unauthorized”: your credentials are missing or expired
403
“forbidden”: you are known, but not allowed
429
“too many requests”: the API server asks you to slow down

When the command itself fails

“Unable to connect to the server”

The request never reached the API server. Common causes are being off the company network or VPN, a wrong cluster address in the kubeconfig, a cluster that was deleted, or a firewall. Fix the path before suspecting Kubernetes.

“You must be logged in” or an unauthorized message

Your token or certificate has expired or is missing. Log in again with your identity provider or refresh the cluster entry in your kubeconfig.

“Forbidden”

The cluster knows who you are but your role does not include this action on this resource in this namespace. The message names the missing permission, so send it to your administrator.

“No resources found”

This is an answer, not an error. It usually means nothing of that type exists in the namespace you are looking at. Check the namespace and context before assuming the resource is gone.

Slow or timing-out lists

In a very large cluster, listing all pods in all namespaces can take long and may time out. Add a namespace or selector, or use the flag that controls the chunk size for paging.

Seeing what kubectl does behind the scenes

kubectl has a verbosity flag that prints the web requests it makes. At a moderate level you see each address it calls and the response code, which is very useful when a command misbehaves. At higher levels, you even see request and response bodies. Use it to learn, but remember the output can contain sensitive data.

Watching the API server itself

Operations teams watch the API server’s own metrics: how many read requests per second, how long they take, and how many return errors. A sudden surge of list requests, often caused by a script that polls too often, can slow down the whole cluster. Audit logs record who made the calls, so the source is easy to find.

Everyday analogy

Using get for health checks is like a caretaker walking around the building at the start of a shift, checking doors and lights. The building’s alarm system and cameras (monitoring and logging) are still needed for the other twenty-three hours of the day.

i
Tip

Do not use loops that run the command every second to wait for something. Use the watch flag, the wait command, or the rollout status command. They put far less load on the cluster and react faster.

12Design Patterns and Anti-patterns

A pattern is a proven way of working. An anti-pattern is a habit that looks sensible at first and causes pain later.

Patterns that work

Pattern

Label everything consistently

Agree on a small set of labels such as app, team and environment, and apply them to every resource. Filtering then becomes effortless and reliable.

Pattern

One namespace per team or application

Small, well-named workspaces keep lists short and let you grant read access with precision.

Pattern

Context always visible

Show the current cluster and namespace in your shell prompt, and use different colours for production. You can never forget where you are.

Pattern

Get, describe, logs

Follow the same order every time you investigate. A habit is faster than improvisation at three in the morning.

Pattern

Machine formats for scripts

Read JSON in automation and keep tables for people. Scripts then survive small wording changes between versions.

Pattern

Desired versus actual

Keep the intended configuration in version control and use get to compare it with what is really running. Differences reveal drift.

Anti-patterns to avoid

ANTI-PATTERN 01 · The polling loop Avoid
The habit

A script that runs the get command every second until a pod is ready.

What goes wrong

Hundreds of pipelines doing this at once flood the API server with requests. The cluster slows down for everyone, and your own script still reacts late.

Better approach

Use the wait command, the rollout status command, or the watch mode. They hold one open connection and are told the instant something changes.

ANTI-PATTERN 02 · Parsing the human table Avoid
The habit

Cutting columns out of the default table with text tools to feed a script.

What goes wrong

Columns can move, names can change with versions, and values containing spaces confuse the slicing. The script breaks silently, often at the worst moment.

Better approach

Ask for JSON or a precise field with a path expression, and read that. The structure is stable and meant for programs.

ANTI-PATTERN 03 · Dumping full records into chat and tickets Avoid
The habit

Pasting the full YAML of a pod or secret to “show the problem”.

What goes wrong

Passwords, tokens and internal addresses end up in chat history and ticket systems where many people can read them, and they remain there for years.

Better approach

Share only the relevant lines, remove sensitive values, and prefer the summary table or a targeted field.

ANTI-PATTERN 04 · Treating “all” as a full inventory Avoid
The habit

Believing that asking for all resources shows everything in the namespace.

What goes wrong

Config maps, secrets, ingresses, storage claims and custom resources are missing from the answer. You conclude that something does not exist when it does.

Better approach

List the resource types you care about explicitly, or use the api-resources command to see every type and query the ones you need.

ANTI-PATTERN 05 · Not checking the context Avoid
The habit

Typing commands without looking at which cluster and namespace are active.

What goes wrong

You inspect, and later change, the wrong environment. Confusing results waste time, and worse, a later action may hit production by mistake.

Better approach

Make the context visible, use separate credentials for production, and get in the habit of a quick glance before every session.

13Best Practices and Common Mistakes

These habits come from many engineers using the command every day. Follow them and you will save yourself a great deal of confusion.

1

Check where you are

Confirm the cluster and namespace before you start, especially after a break or when switching tasks.

2

Start narrow

Use a namespace and a label selector first. Widen the search only if you find nothing.

3

Read two columns together

STATUS and READY tell one story only when read as a pair. Restarts and age add the rest.

4

Use the right output for the job

Table for people, wide for location, YAML for study, JSON for scripts.

5

Sort events by time

Events are not listed in order by default. Sort by creation time to read the story from start to finish.

6

Set up completion and a short alias

Shell completion for kubectl and a one-letter alias save thousands of keystrokes and reduce typos.

7

Keep the tool current

Use a kubectl version within one minor release of your cluster to avoid strange behaviour and warnings.

Common mistakes and their cures

MistakeWhat you seeCure
Wrong namespace“No resources found” although the application runsAdd the namespace flag or the all-namespaces flag
Wrong cluster or contextUnexpected pods, or nothing familiar at allCheck and switch the current context
Reading only STATUSA “Running” pod that serves no trafficRead the READY column too
Expired credentialsUnauthorized message on every commandLog in again or refresh the kubeconfig entry
Missing permissionForbidden message naming a verb and resourceAsk for a read role in that namespace
Unknown resource type“The server doesn’t have a resource type”Check spelling, and list available types; a custom type may not be installed in this cluster
Unsorted eventsA confusing, jumbled storySort by creation time
Using get to confirm a rollout finishedA snapshot that looks fine while updates continueUse the rollout status command, which waits for completion
Huge unfiltered listingSlow answer or timeoutAdd a namespace, selector, or paging
i
A debugging order that works

When something looks wrong, ask in this order: Am I in the right cluster? The right namespace? Do I have permission? Does the resource exist? What do STATUS and READY say? What do the events say? Answering these in sequence solves most problems in minutes.

14Real-World Usage Stories

Engineers in organisations of every size use this command all day. The stories below are simplified illustrations of common situations, not descriptions of any one company’s private setup.

An on-call engineer at a large marketplace

Think of a marketplace on the scale of Amazon or Flipkart. An alert says checkout errors are rising. The engineer opens a terminal, lists the checkout pods, and sees three in CrashLoopBackOff with high restart counts. Within a minute they know which service and which release to look at, and they move on to describing and reading logs.

Release day for a software-as-a-service company

A team ships a new version. One engineer keeps the watch mode running on the deployment’s pods and sees new ones appear, become Ready, and old ones disappear. If new pods stay Pending or crash, the team stops the rollout early, before customers notice.

A security review

An auditor asks which container images are running across the cluster. A single get with a custom output prints every pod and its images. The team compares the list against approved versions and finds two outdated images to fix.

A cost clean-up

A platform team lists storage claims across all namespaces, sorted by age, and finds dozens that no pod uses. After checking with the owners, they remove them and reduce the monthly cloud bill.

A new engineer’s first day

A newcomer learns the shape of the system by listing namespaces, then deployments in each, then services. In an hour they have a mental map, without reading a single document.

A pipeline that waits for readiness

A deployment pipeline applies a change and then waits, using the rollout status command, until the new pods are ready. Only then does it run smoke tests. This is safer and lighter than a script that repeatedly lists pods.

i
Big picture

In every story the pattern is the same: look first with a quick, safe command, form a guess, then choose deeper tools. The get command is the starting point of nearly every investigation, every rollout and every review.

15Frequently Asked Questions

Q1Does kubectl get change anything in the cluster?
No. It only reads and displays information. It sends a read request to the API server and prints the answer, so you can run it as often as you like.
Q2What is the difference between get and describe?
Get gives a compact summary of one or many resources. Describe gives a detailed, human-readable report about one resource, including its recent events, which usually explain why it is in its current state.
Q3Why does it say “No resources found”?
That means the request worked but the answer is empty for the place you looked. The most common reason is the wrong namespace or cluster. Try the all-namespaces flag or check the current context.
Q4How do I see resources in every namespace?
Add the all-namespaces flag, written as a capital A. The output gains a namespace column so you can tell where each item lives.
Q5How can I see which computer a pod is running on?
Ask for the wide output. It adds columns including the node name and the pod’s internal address.
Q6How do I see the labels on my resources?
Use the show-labels flag to add a labels column. To add a column for one specific label, use the capital L flag with the label’s name.
Q7Can I use get for custom resource types?
Yes. Extensions that add new resource types, called custom resources, work with get in the same way, and they can even define their own helpful columns. The api-resources command lists every type your cluster knows.
Q8Why doesn’t “all” show everything?
“All” is a shortcut for a fixed group of common types. It does not include many others such as config maps, secrets, ingresses and storage claims. Name the types you want explicitly.
Q9How do I watch a resource change live?
Add the watch flag. The command stays open and prints a new line each time a matching resource changes. Press Control and C to stop.
Q10Is it safe to run on a production cluster?
It is safe in the sense that it changes nothing. Still, be careful: full-record output can reveal secrets, and very large unfiltered lists can burden the API server. Use narrow queries and share output carefully.
Q11Does get show the values of secrets?
The table shows only names and basic details. The YAML or JSON output of a secret shows its values in base64 encoding, which anyone can decode. Restrict who may read secrets and handle such output with care.

16Summary and Key Takeaways

Key Takeaways

  • Get is your eyes on the cluster. It asks the API server for resources and prints a live summary, without changing anything.
  • Learn the anatomy. The tool, the verb, the resource type, an optional name and optional flags are all you need to read or write almost any variation.
  • Narrow before you widen. Namespaces, label selectors and field selectors give faster answers and put less load on the cluster.
  • Read columns as a pair. STATUS and READY together, plus RESTARTS and AGE, tell the real story of a pod.
  • Pick the right format. Tables for people, wide for location, YAML for study, JSON or custom columns for scripts and audits.
  • Read-only is not risk-free. Secrets appear in full-record output, wrong contexts mislead, and wide access should be limited by role.
  • Get starts investigations, it does not finish them. Follow with describe, logs and top for reasons and numbers, and use watch, wait and rollout status instead of polling loops.