【问题标题】:How to profile service running on kubernetes pod?如何分析在 kubernetes pod 上运行的服务?
【发布时间】:2021-10-12 18:42:21
【问题描述】:

我想用 perf/flame 图分析部署在 k8s 集群上的服务,但无法将其安装在 pod 中。我的程序是用 C++ 编写的,所以很遗憾无法使用插件 kubectl flame 进行分析。

root@mypod:/app# perf
WARNING: perf not found for kernel 5.4.0-1044

  You may need to install the following packages for this specific kernel:
    linux-tools-5.4.0-1044-gke
    linux-cloud-tools-5.4.0-1044-gke

  You may also want to install one of the following packages to keep up to date:
    linux-tools-gke
    linux-cloud-tools-gke
root@mypod:/app# apt-get install -y linux-tools-5.4.0-1044-gke
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package linux-tools-5.4.0-1044-gke
E: Couldn't find any package by glob 'linux-tools-5.4.0-1044-gke'
E: Couldn't find any package by regex 'linux-tools-5.4.0-1044-gke'
root@mypod:/app# 
root@mypod:/app# apt-get install -y linux-cloud-tools-5.4.0-1044-gke
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package linux-cloud-tools-5.4.0-1044-gke
E: Couldn't find any package by glob 'linux-cloud-tools-5.4.0-1044-gke'
E: Couldn't find any package by regex 'linux-cloud-tools-5.4.0-1044-gke'

或者有其他方法吗?

【问题讨论】:

    标签: c++ kubernetes profile


    【解决方案1】:

    两种最常见的“无修改”跟踪工具是 bpftrace 和 systemtap。不知道是否可以在 GKE 的 COS 上运行,但您肯定需要从工具沙箱内的实际 VM 中执行此操作,而不是从 pod 内执行。或者可以使用 gprof,但这需要在激活分析支持的情况下编译可执行文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-17
      • 2020-06-28
      • 1970-01-01
      • 1970-01-01
      • 2022-11-24
      • 1970-01-01
      • 2023-01-10
      • 2021-05-03
      相关资源
      最近更新 更多