kubectl get
| 字段 |
常用格式 |
说明 |
参数 |
| node |
kubectl get node |
节点 |
—all-namespaces |
|
kubectl get node -o wide |
|
-n default |
| pods |
kubectl get pods |
获取pod |
-n kube-system |
|
kubectl get pods -o wide |
|
|
|
kubectl get pods -o wide —all-namespaces |
|
|
| replicasets |
kubectl get repllicaset |
和pod相似 |
|
|
|
|
|
| deployment |
kubectl get Deployment |
获取部署 |
|
| deployments |
kubectl get deployments |
|
|
|
|
|
|
| DaemonSet |
kubectl get DaemonSet |
获取守护程序 |
|
|
|
|
|
| svc(services) |
kubectl get svc |
获取服务 |
-A |
|
kubectl get services |
|
|
|
|
|
|
| rc |
kubectl get rc |
获取资源 |
|
|
|
|
|
| delete nodes |
kubectl delete nodes node03 |
删除节点 |
|
|
|
|
|
| ns |
kubectl get ns |
查看命名空间 |
|
| ingress |
|
|
|
| ingressClass |
|
|
|
| validatingwebhookconfigurations |
|
|
|
| logs |
|
|
|
| describe |
describe pod xxx |
|
|
|
|
|
|
|
|
|
kubectl get
# 以ps输出格式列出所有Pod
kubectl get pods
# 以ps输出格式列出所有Pod,并提供更多信息(如节点名称)
kubectl get pods -o wide
#以JSON输出格式列出单个pod
kubectl get -o json pod web-pod-13je7
# 以ps输出格式列出具有指定名称的单个复制控制器
kubectl get replicationcontroller web
# 在 v1版的appsAPI组本中 以JSON输出格式列出部署
kubectl get deployments.v1.apps -o json
# 以JSON输出格式列出由“pod.yaml”中指定的类型和名称标识的pod
kubectl get -f pod.yaml -o json
# 使用kustomization.yaml列出目录中的资源,例如dir/kustomization.yaml
kubectl get -k dir/
# 仅返回指定pod的相位值
kubectl get -o template pod/web-pod-13je7 --template={{.status.phase}}
# 在自定义列中列出资源信息
kubectl get pod test-pod -o custom-columns=CONTAINER:.spec.containers[0].name,IMAGE:.spec.containers[0].image
# 以ps输出格式列出所有复制控制器和服务
kubectl get rc,services
# 按类型和名称列出一个或多个资源
kubectl get rc/web service/frontend pods/web-pod-13je7
# 列出单个pod的“status”子资源
kubectl get pod web-pod-13je7 --subresource status