查看全部 pod 列表, -n 后跟 namespace, 查看指定的命名空间node
kubectl get pod kubectl get pod -n kube kubectl get pod -o wide
查看 RC 和 service 列表, -o wide 查看详细信息redis
kubectl get rc,svc kubectl get pod,svc -o wide kubectl get pod <pod-name> -o yaml
显示 Node 的详细信息api
kubectl describe node 192.168.0.212
显示 Pod 的详细信息, 特别是查看 pod 没法建立的时候的日志bash
kubectl describe pod <pod-name> eg: kubectl describe pod redis-master-tqds9
根据 yaml 建立资源, apply 能够重复执行,create 不行app
kubectl create -f pod.yaml kubectl apply -f pod.yaml
基于 pod.yaml 定义的名称删除 podide
kubectl delete -f pod.yaml
删除全部包含某个 label 的pod 和 servicespa
kubectl delete pod,svc -l name=<label-name>
删除全部 Pod日志
kubectl delete pod --all
查看 endpoint 列表code
kubectl get endpoints
执行 pod 的 date 命令资源
kubectl exec <pod-name> -- date kubectl exec <pod-name> -- bash kubectl exec <pod-name> -- ping 10.24.51.9
经过bash得到 pod 中某个容器的TTY,至关于登陆容器
kubectl exec -it <pod-name> -c <container-name> -- bash eg: kubectl exec -it redis-master-cln81 -- bash
查看容器的日志
kubectl logs <pod-name> kubectl logs -f <pod-name> # 实时查看日志 kubectl log <pod-name> -c <container_name> # 若 pod 只有一个容器,能够不加 -c
查看注释
kubectl explain pod kubectl explain pod.apiVersion