Kubernetes has quickly grown to become one of the most popular container orchestration frameworks in the industry. Kubernetes has many benefits and it known for its flexibility and ease of use. With its growing community, many tools and technologies have been developed to make it simple to use.
<terminal inline>kubectl<terminal inline> is one of the most popular open-source CLIs for interacting with a Kubernetes cluster. In this guide, you will learn about <terminal inline>describe<terminal inline>, one of its popular commands.
What is kubectl describe Used For?
As is evident by its name, the <terminal inline>kubectl describe<terminal inline> command is used to view details of a Kubernetes resource or resource group. Here's how it's used:
Common resource types include pods, services, nodes, events, and more. The command takes the prefix of the resource name as input. You can also provide the complete name of the resource and it would work just fine.
Here's how you can use this command:
Here's what the output would look like:
Exploring kubectl describe in Detail
The <terminal inline>kubectl describe<terminal inline> command provides a few options to tailor it to your liking. Here are some of those:
Viewing by label
You can also use metadata labels to filter and identify resources when describing them. Here's what the syntax looks like for that:
Viewing resources using a file
The <terminal inline>kubectl describe<terminal inline> command allows you to query for resources using data stored in a file. Here's what the syntax looks like:
You can use the following syntax too:
It works the same as the syntax shared at the beginning of the article.
kubectl describe vs kubectl get
People often debate on whether or not <terminal inline>describe<terminal inline> was needed when there already was a <terminal inline>get<terminal inline> command. To understand this better, let's try to view them side by side:
Here's what a <terminal inline>get<terminal inline> command on a pod returns:
Here's what a <terminal inline>describe<terminal inline> call on the same pod returns:
As you can see, the get command (by default) returns a very quick summary of the status of the resource in question. On the other hand, the describe command prepares a detailed summary of the resource with additional details like container ID, limits, node details, etc.
Also, the <terminal inline>get<terminal inline> command returns the information in a tabular fashion by default. You also have the option to view the information in any other format such as JSON or YAML by passing it as an option. But, the output returned in such a case is quite verbose and is usually difficult to read.
At the end of the day, <terminal inline>describe<terminal inline> provides you with just the right amount of information about your K8s resource. If you are looking for anything less or more, you should look towards <terminal inline>get<terminal inline>.
K8s is one of the popular container-orchestration technologies in use right now. The <terminal inline>kubectl describe<terminal inline> command enables developers to look into the current state of their Kubernetes resources. In this guide, we showed you how to use this command as well as contrasted it with another popular command that does a similar job.