Kubectl常用命令

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> {} -f --tail 500
快速查询所有pod
kubectl get pods -A -o wide | grep "aaa"
查询对应pod的yaml信息
kubectl get pod podname -n namespace -o yaml
条件检索pod
k get pods -A | grep <podname>
删除并更新服务
kubectl delete -f nginx-web.yaml 
kubectl apply -f nginx-web.yaml
  • 5
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值