容器编排技术 -- Kubernetes kubectl get 命令详解
容器编排技术 -- Kubernetes kubectl get 命令详解
- 1 kubectl get
- 2 语法
- 3 示例
- 4 Flags
kubectl get
获取列出一个或多个资源的信息。
可以使用的资源包括:
- all
- certificatesigningrequests (aka 'csr')
- clusterrolebindings
- clusterroles
- clusters (valid only for federation apiservers)
- componentstatuses (aka 'cs')
- configmaps (aka 'cm')
- controllerrevisions
- cronjobs
- daemonsets (aka 'ds')
- deployments (aka 'deploy')
- endpoints (aka 'ep')
- events (aka 'ev')
- horizontalpodautoscalers (aka 'hpa')
- ingresses (aka 'ing')
- jobs
- limitranges (aka 'limits')
- namespaces (aka 'ns')
- networkpolicies (aka 'netpol')
- nodes (aka 'no')
- persistentvolumeclaims (aka 'pvc')
- persistentvolumes (aka 'pv')
- poddisruptionbudgets (aka 'pdb')
- podpreset
- pods (aka 'po')
- podsecuritypolicies (aka 'psp')
- podtemplates
- replicasets (aka 'rs')
- replicationcontrollers (aka 'rc')
- resourcequotas (aka 'quota')
- rolebindings
- roles
- secrets
- serviceaccounts (aka 'sa')
- services (aka 'svc')
- statefulsets
- storageclasses
- thirdpartyresources
语法
$ get [(-o|--output=)json|yaml|wide|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=...] (TYPE [NAME | -l label] | TYPE/NAME ...) [flags]
示例
列出所有运行的Pod信息。
kubectl get pods
列出Pod以及运行Pod节点信息。
kubectl get pods -o wide
列出指定NAME的 replication controller信息。
kubectl get replicationcontroller web
以JSON格式输出一个pod信息。
kubectl get -o json pod web-pod-13je7
以“pod.yaml”配置文件中指定资源对象和名称输出JSON格式的Pod信息。
kubectl get -f pod.yaml -o json
返回指定pod的相位值。
kubectl get -o template pod/web-pod-13je7 --template={{.status.phase}}
列出所有replication controllers和service信息。
kubectl get rc,services
按其资源和名称列出相应信息。
kubectl get rc/web service/frontend pods/web-pod-13je7
列出所有不同的资源对象。
kubectl get all
Flags
Name | Shorthand | Default | Usage |
---|---|---|---|
all-namespaces | false | If present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace. | |
allow-missing-template-keys | true | If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. | |
experimental-use-openapi-print-columns | false | If true, use x-kubernetes-print-column metadata (if present) from openapi schema for displaying a resource. | |
export | false | If true, use 'export' for the resources. Exported resources are stripped of cluster-specific information. | |
filename | f | [] | Filename, directory, or URL to files identifying the resource to get from a server. |
ignore-not-found | false | Treat "resource not found" as a successful retrieval. | |
include-extended-apis | true | If true, include definitions of new APIs via calls to the API server. [default true] | |
label-columns | L | [] | Accepts a comma separated list of labels that are going to be presented as columns. Names are case-sensitive. You can also use multiple flag options like -L label1 -L label2... |
no-headers | false | When using the default or custom-column output format, don't print headers (default print headers). | |
output | o | Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath]. | |
output-version | DEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob'). | ||
raw | Raw URI to request from the server. Uses the transport specified by the kubeconfig file. | ||
recursive | R | false | Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. |
schema-cache-dir | ~/.kube/schema | If non-empty, load/store cached API schemas in this directory, default is '$HOME/.kube/schema' | |
selector | l | Selector (label query) to filter on, supports '=', '==', and '!='. | |
show-all | a | false | When printing, show all resources (default hide terminated pods.) |
show-kind | false | If present, list the resource type for the requested object(s). | |
show-labels | false | When printing, show all labels as the last column (default hide labels column) | |
sort-by | If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. | ||
template | Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. | ||
watch | w | false | After listing/getting the requested object, watch for changes. |
watch-only | false | Watch for changes to the requested object(s), without listing/getting first. |
容器编排技术 -- Kubernetes kubectl get 命令详解相关推荐
- 容器编排技术 -- Kubernetes kubectl scale 命令详解
容器编排技术 -- Kubernetes kubectl scale 命令详解 1 kubectl scale 2 语法 3 示例 4 Flags kubectl scale 扩容或缩容 Deploy ...
- 容器编排技术 -- Kubernetes kubectl rolling-update 命令详解
容器编排技术 -- Kubernetes kubectl rolling-update 命令详解 1 kubectl rolling-update 2 语法 3 示例 4 Flags kubectl ...
- 容器编排技术 -- Kubernetes kubectl replace 命令详解
容器编排技术 -- Kubernetes kubectl replace 命令详解 1 kubectl replace 2 语法 3 示例 4 Flags kubectl replace 使用配置文件 ...
- 容器编排技术 -- Kubernetes kubectl patch 命令详解
容器编排技术 -- Kubernetes kubectl patch 命令详解 1 kubectl patch 2 语法 3 示例 4 Flags kubectl patch 使用(patch)补丁修 ...
- 容器编排技术 -- Kubernetes kubectl label 命令详解
容器编排技术 -- Kubernetes kubectl label 命令详解 1 kubectl label 2 语法 3 示例 4 Flags kubectl label 更新(增加.修改或删除) ...
- 容器编排技术 -- Kubernetes kubectl edit 命令详解
容器编排技术 -- Kubernetes kubectl edit 命令详解 1 kubectl edit 2 语法 3 示例 4 Flags kubectl edit 使用默认编辑器 编辑服务器上定 ...
- 容器编排技术 -- Kubernetes kubectl delete 命令详解
容器编排技术 -- Kubernetes kubectl delete 命令详解 1 kubectl delete 2 语法 3 示例 4 Flags kubectl delete 通过配置文件名.s ...
- 容器编排技术 -- Kubernetes kubectl create 命令详解
容器编排技术 -- Kubernetes kubectl create 命令详解 1 kubectl create 2 语法 3 示例 4 Flags kubectl create 通过配置文件名或s ...
- 容器编排技术 - Kubernetes kubectl convert 命令详解
容器编排技术 - Kubernetes kubectl convert 命令详解 1 kubectl convert 2 语法 3 示例 4 Flags kubectl convert 转换配置文件 ...
最新文章
- 如何看待程序媛们的职场焦虑和未来职业规划?
- 网页打开慢与服务器有关吗,网站打开好慢! 原来是这些原因造成的
- HTML5之内嵌框架
- Windows下完成端口移植Linux下的epoll
- Objective-c 创建类的使用
- 在 SAP Gateway Demo System ES5 申请用户遇到问题该怎么处理
- linux python安装教程_Linux系统如何安装Python?新手教程
- mybatis oracle 多条件批量删除_面试官经常喜欢问的Mybatis经典面试题,值得好好收藏哦!...
- linux chown 命令
- HBase的rowKey设计技巧
- java关闭自动更新_怎么关闭java自动更新
- badboy设置中文_badboy基本操作
- FPGA入门-腾讯云布道师团队-专题视频课程
- 朋友圈文案_隐私条款
- 获取手机机身和外置SD卡存储容量的方法
- 触碰十年后的自己(2026年)
- R7 5800H和i5 11300H参数对比差距大不大
- 团宝欠薪裁员续:合作商家停止接待团宝顾客
- 人类遗传密码97%待解读
- 劲爆!开源芯片死结打开了?道翰天琼认知智能机器人平台API接口大脑为您揭秘