kubectl:描述vs get -o< format> [英] kubectl: describe vs get -o <format>
问题描述
在kubectl中,describe
和get -o <format>
都可以用来获取资源的详细信息,我想知道两者之间有什么区别?如果get
可以做同样的事情甚至更多,为什么describe
甚至存在?
In kubectl, both describe
and get -o <format>
can be used to get the details of a resource, I'm wondering what's the difference between the two? why does describe
even exist if get
can do the same thing and more?
推荐答案
-
kubectl get
默认显示表格. (您可以轻松查看/可视化大量对象)kubectl get
shows tables by default. (You can view/visualize large no of objects easily)kubectl describe
显示详细说明. (最好是单个对象)kubectl describe
shows the detailed description. (Better for a single object)kubectl describe
更平整,数据更少,更易于读取
kubectl describe
is more flattened, has lesser data and easier to read than the full object data given bykubectl get -o yaml
帮助输出以供参考.
kubectl describe -h
Show details of a specific resource or group of resources Print a detailed description of the selected resources, including related resources such as events or controllers. You may select a single object by name, all objects of that type, provide a name prefix, or label selector. For example: $ kubectl describe TYPE NAME_PREFIX will first check for an exact match on TYPE and NAME_PREFIX. If no such resource exists, it will output details for every resource that has a name prefixed with NAME_PREFIX. Use "kubectl api-resources" for a complete list of supported resources.
kubectl get -h
Display one or many resources Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is namespaced you will only see results in your current namespace unless you pass --all-namespaces. Uninitialized objects are not shown unless --include-uninitialized is passed. By specifying the output as 'template' and providing a Go template as the value of the --template flag, you can filter the attributes of the fetched resources. Use "kubectl api-resources" for a complete list of supported resources.
这篇关于kubectl:描述vs get -o< format>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!