Kubectl
查看pod所在节点
kubectl get pod -n namepsace -o wide
查看pod服务
kubectl get po -n namespace |grep podname
查看服务日志
kubectl logs -f --tail 1000 pod -n namespace
进入pod容器内部
kubectl exec -it podname -n namespace /bin/bash -n namespace
根据条件查询日志
kubectl logs -f <podname> -n <namespace> | grep 平均幅度图
kubectl logs <pod_name> | grep -A <num_after_lines> -B <num_before_lines> <search_pattern>
-
<pod_name>
:要查看日志的 Pod 名称。
-
<num_after_lines>
:条件出现后要显示的行数。
-
<num_before_lines>
:条件出现前要显示的行数。
-
<search_pattern>
:要搜索的模式或关键字。
kubectl get pods -n <namespace> | grep <podname> | awk '{print $1}' | xargs -I {} kubectl logs -n <namespace&g