#查看k8s的所有node節點
kubectl get node
#查看ns的pod
kubectl get pod --all-namespaces -o wide
kubectl get pod -n kube-system
# 顯示 Node 的詳細信息
kubectl describe node pnode-5
# 顯示 Pod 的詳細信息, 特別是查看 pod 無法創建的時候的日志
kubectl describe pod <pod-name> -n <ns-name>
# 查看 RC 和 service 列表, -o wide 查看詳細信息
kubectl get rc,svc
kubectl get pod,svc -o wide
#查看pod的yaml文件
kubectl get pod <pod-name> -n <ns-name> -o yaml
#查看pod的日志
kubectl logs <pod-name> -n <ns-name>
kubectl logs -f <pod-name> -n <ns-name>
# 根據 yaml 創建資源, apply 可以重復執行,create 不行
kubectl create -f pod.yaml
kubectl apply -f pod.yaml
# 基於 pod.yaml 定義的名稱刪除 pod
kubectl delete -f pod.yaml
# 刪除所有包含某個 label 的pod 和 service
kubectl delete pod,svc -l name=<label-name>
# 查看 endpoint 列表
kubectl get endpoints
# 通過bash獲得 pod 中某個容器的TTY,相當於登錄容器
kubectl exec -it <pod-name> -n <ns-name> bash
#編輯pod的yaml文件
kubectl get deployment -n <ns-name>
kubectl edit depolyment <pod-name> -n <ns-name> -o yaml
