kubectl exec 进入pod后,exit退出pod (ctrl+c也可以?)
在 pod 外执行容器命令
===========================================================
#kubectl 查看 K8s 内节点、Pod 资源使用情况
kubectl describe node 查看 Pod 在节点上的资源分配情况(Request、Limits)
kubectl top node 查看节点的资源使用情况
kubectl top pod 查看 Pod 资源使用情况
kubectl get pod -o wide |grep node查看指定node上运行的所有podkubectltoppod∣grep−E“node 查看指定 node 上运行的所有 pod kubectl top pod |grep -E “node查看指定node上运行的所有podkubectltoppod∣grep−E“podname1|$podname2|…” 查看一个 pod 或几个 pod 的资源使用情况
===========================================================
#kubectl get - 列出一个或多个资源
kubectl cluster-info
kubectl get cs
kubectl get pods -o wide
kubectl get pods -n mynamespace -o wide #-n namesapce的
kubectl get pods -A -o wide #-A 所有namesapce的
kubectl get nodes
kubectl get ns
kubectl get svc -n kube-system
kubectl get pods
kubectl get pods --field-selector=spec.nodeName=server01
kubectl get replicationcontroller
kubectl get rc,services
kubectl get ds --include-uninitialized
===========================================================
describe命令
#kubectl describe - 显示一个或多个资源的详细状态,默认情况下包括未初始化的资源。
kubectl describe nodes
kubectl describe pods/
kubectl describe pods
kubectl describe pods --include-uninitialized=false
说明: kubectl get 命令通常用于检索同一资源类型的一个或多个资源。 它具有丰富的参数,允许您使用 -o 或 --output 参数自定义输出格式。您可以指定 -w 或 --watch 参数以开始观察特定对象的更新。 kubectl describe 命令更侧重于描述指定资源的许多相关方面。它可以调用对 API 服务器 的多个 API 调用来为用户构建视图。 例如,该 kubectl describe node 命令不仅检索有关节点的信息,还检索在其上运行的 pod 的摘要,为节点生成的事件等。
======================================================
delete命令
#kubectl delete` - 从文件、stdin 或指定标签选择器、名称、资源选择器或资源中删除资源。
kubectl delete -f pod.yaml
kubectl delete pods,services -l name=
kubectl delete pods,services -l name= --include-uninitialized
kubectl delete pods --all
进入容器命令
#kubectl exec - 对 pod 中的容器执行命令。与docker的exec命令非常类似
kubectl exec date
kubectl exec -c date
kubectl exec -ti /bin/bash
logs命令
kubectl logs - 打印 Pod 中容器的日志。
kubectl logs
kubectl logs -f
下一篇:C语言学习笔记(十)