Kubernetes 常用命令

Kubernetes 通过 Kube Apiserver 作为整个集群管理的入口。Apiserver 是整个集群的主管理节点,用户通过 Apiserver 配置和组织集群,同时集群中各个节点同 etcd 存储的交互也是通过 Apiserver 进行交互。

Apiserver 实现了一套 RESTful 的接口,用户可以直接使用 API 同 Apiserver 交互。另外官方还提供了一个客户端 kubectl 随工具集打包,用于可直接通过 kubectl 以命令行的方式同集群交互。

help

  • |

get

注:集群中可以创建多个 namespace,未指定 namespace 情况下,所有操作都是针对 default namespace。

  • kubectl get po

          当前运行的所有 pods 的信息。

  • kubectl get po -o wide

          获取 pod 运行在哪个节点上的信息。

  • kubectl get po

          显示 default namespace 下的 pods。

  • kubectl get po --namespace=

          显示指定 namespace下的 pods。

  • kubectl get po --all-namespaces

          显示所有 namespace 的 pods。

  • kubectl get pod --selector name=redis

          按 selector 名来查找 pod。

  • kubectl get namespace

  • kubectl get rc

  • kubectl get svc

  • kubectl get nodes

  • kubectl get node --show-labels

 获取一些更具体的信息,可以通过使用选项“-o”:

  • kubectl get po -o yaml

          以 yawl 格式输出 pod 的详细信息

  • kubectl get po -o json

          以 json 格式输出 pod 的详细信息

  • -o=custom-columns=

你可能感兴趣的:(《容器》,kubernetes,容器,云原生)