K8s kubectl get操作
来源:互联网 发布:怎么在淘宝买电棒 编辑:程序博客网 时间:2024/06/05 03:45
总结了一些这两天使用Kubernetes master主机上的一些操作,顺手记录下来
获取node信息
$ kubectl get nodes$ kubectl get nodes --show-labels
截取hostname行
$ kubectl describe nodes |grep kubernetes.io/hostname=$ kubectl describe nodes 10.1.235.165 |grep kubernetes.io/hostname=
给node打标签
$ kubectl label nodes {nodeName} {key=value}$ kubectl label nodes 10.1.235.165 ijk=test
删除该标签
$ kubectl label nodes {nodeName} {key-}$ kubectl label nodes 10.1.235.165 ijk-
获取yaml/json格式的详细信息
$ kubectl get namespace joetest814 -o yaml$ kubectl get node 10.1.235.165 -o json
获取deployment信息
$ kubectl get deploy --all-namespaces$ kubectl get deploy --namespace=joetest815
有待补充…
下面贴上$ kubectl get –help的说明
Display one or many resources.
Valid resource types include:
- clusters (valid only for federation apiservers) *
componentstatuses (aka ‘cs’) * configmaps (aka ‘cm’) *
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 *
nodes (aka ‘no’) * persistentvolumeclaims (aka ‘pvc’) *
persistentvolumes (aka ‘pv’) * pods (aka ‘po’) *
podsecuritypolicies (aka ‘psp’) * podtemplates * replicasets
(aka ‘rs’) * replicationcontrollers (aka ‘rc’) *
resourcequotas (aka ‘quota’) * secrets * serviceaccounts (aka
‘sa’) * services (aka ‘svc’) * statefulsets *
storageclasses * thirdpartyresourcesThis command will hide resources that have completed. For instance,
pods that are in the Succeeded or Failed phases. You can see the full
results for any resource by providing the ‘–show-all’ flag.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 resource(s).Examples: # List all pods in ps output format. kubectl get pods
# List all pods in ps output format with more information (such as node name). kubectl get pods -o wide
# List a single replication controller with specified NAME in ps output format. kubectl get replicationcontroller web
# List a single pod in JSON output format. kubectl get -o json pod web-pod-13je7
# List a pod identified by type and name specified in “pod.yaml” in JSON output format. kubectl get -f pod.yaml -o json
# Return only the phase value of the specified pod. kubectl get -o template pod/web-pod-13je7 –template={{.status.phase}}
# List all replication controllers and services together in ps output format. kubectl get rc,services
# List one or more resources by their type and names. kubectl get rc/web service/frontend pods/web-pod-13je7Options:
–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.
–export=false: If true, use ‘export’ for the resources. Exported resources are stripped of cluster-specific information. -f,
–filename=[]: Filename, directory, or URL to files identifying the resource to get from a server.
–include-extended-apis=true: If true, include definitions of new APIs via calls to the API server. [default true] -L,
–label-columns=[]: 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. -o, –output=”: 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=”: Output the formatted object with the given group version (for ex: ‘extensions/v1beta1’).
–raw=”: Raw URI to request from the server. Uses the transport specified by the kubeconfig file. -R, –recursive=false:
Process the directory used in -f, –filename recursively. Useful when
you want to manage related manifests organized within the same
directory. -l, –selector=”: Selector (label query) to filter on
-a, –show-all=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].
-w, –watch=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.
- K8s kubectl get操作
- k8s kubectl命令补齐
- kubectl基本操作
- 【原创】k8s源码分析-----kubectl(1)api.RESTMapper
- 【原创】k8s源码分析-----kubectl(2)Factory
- 【原创】k8s源码分析-----kubectl(3)主要框架
- K8S客户端Kubectl无法下载问题的解决办法-到中科大USTC下载
- apt-get无法获取kubelet kubeadm kubectl包
- docker和k8s基本操作
- k8s
- pod中state与laststate及kubectl get pod中的status的关联
- kubectl常用命令
- kubectl常用命令
- 使用client-go 进行k8s相关操作-clientset(一)
- 使用client-go 进行k8s相关操作-dynamicclient(二)
- 使用client-go 进行k8s相关操作-restclient(三)
- [k8s]k8s rbac语法
- [k8s]k8s架构图解
- JD-GUI反编译后代码逻辑分析
- 写递归函数的正确思维方法
- CISM国际注册信息安全经理认证
- [容易] priority_queue版Huffman
- webpack打包
- K8s kubectl get操作
- 数据盘分区以及格式化
- jmeter检查点
- 基于 UAP 的 Web Service 开发
- C++将析构函数定义成virtual的原因
- GPIO
- javascript权威指南--第七章
- CRC校验笔记
- Caused by: org.springframework.beans.factory.BeanCreationException