简体   繁体   English

分析kubernetes pod网络流量

[英]Analyse kubernetes pod network traffic

All,全部,

Off late my cloud provider is charging more for data transfer.迟到了,我的云提供商对数据传输收取更多费用。 Finally noticed one of the K8 pod is having more data transfer.终于注意到其中一个 K8 吊舱有更多的数据传输。 Is there a way i can find out pod level network traffic such us how much transmitted and received bytes with native kubernetes command?有没有办法我可以通过本机 kubernetes 命令找出 pod 级别的网络流量,例如我们发送和接收的字节数?

Thanks Bala谢谢巴拉

kubectl top command shows usage , not allocation. kubectl top命令显示使用情况,而不是分配情况。 Allocation is what causes the insufficient CPU problem.分配是导致insufficient CPU问题的原因。 There's a ton of confusion in this issue about the difference.这个问题有很多关于差异的混淆。

AFAICT, there's no easy way to get a report of node CPU allocation by pod, since requests are per container in the spec. AFAICT,没有简单的方法来获取 pod 的节点 CPU 分配报告,因为请求是在规范中的每个容器。 And even then, it's difficult since .spec.containers[*].requests may or may not have the limits / requests fields.即使那样,这也很困难,因为.spec.containers[*].requests可能有也可能没有limits / requests字段。 But there is something like kubectl-view-allocations with it you can explore your kube resource usage and allocation.但是有类似kubectl-view-allocations的东西,你可以探索你的 kube 资源使用和分配。 It can provide result grouped by namespaces, nodes, pods and filtered by resources'name.它可以提供按命名空间、节点、pod 分组并按资源名称过滤的结果。

kubectl-view-allocations [FLAGS] [OPTIONS]

FLAGS:
    -h, --help         Prints help information
    -z, --show-zero    Show lines with zero requested and zero limit and zero allocatable
    -V, --version      Prints version information

OPTIONS:
    -g, --group-by <group-by>...              Group informations (hierarchicaly) (default: -g resource -g node -g pod)
                                              [possible values: resource, node, pod]
    -n, --namespace <namespace>               Show only pods from this namespace
    -r, --resource-name <resource-name>...    Filter resources shown by name(s), by default all resources are listed

In your case I think safest option is to install Heapster or metrics-server , cAdvisor and Grafana .在您的情况下,我认为最安全的选择是安装Heapstermetrics-servercAdvisorGrafana

Heapster enables Container Cluster Monitoring and Performance Analysis for Kubernetes (versions v1.0.6 and higher), and platforms which include it. Heapster 为Kubernetes (版本 v1.0.6 及更高版本)以及包含它的平台启用容器集群监控和性能分析。

Heapster collects and interprets various signals like compute resource usage - with this metrics you will find the problem wit htransfering more data by specific pods, lifecycle events, etc. Heapster supports multiple sources of data. Heapster 收集和解释各种信号,如计算资源使用情况 - 使用此指标,您会发现通过特定 pod、生命周期事件等传输更多数据的问题。Heapster 支持多种数据源。

Container metrics are available mostly through cAdvisor.容器指标主要通过 cAdvisor 提供。 cAdvisor (Container Advisor) provides container users an understanding of the resource usage and performance characteristics of their running containers. cAdvisor (Container Advisor) 让容器用户了解他们正在运行的容器的资源使用和性能特征。 It is a running daemon that collects, aggregates, processes, and exports information about running containers.它是一个正在运行的守护进程,用于收集、聚合、处理和导出有关正在运行的容器的信息。 Specifically, for each container it keeps resource isolation parameters, historical resource usage, histograms of complete historical resource usage and network statistics.具体来说,它为每个容器保存资源隔离参数、历史资源使用情况、完整历史资源使用情况的直方图和网络统计信息。 This data is exported by container and machine-wide.此数据由容器和机器范围导出。

Grafana on the other hand allows you to query, visualize, alert on and understand gathered metrics no matter where they are stored.另一方面,Grafana 允许您查询、可视化、提醒和了解收集的指标,无论它们存储在哪里。 Create, explore, and share dashboards with your team and foster a data driven culture.与您的团队创建、探索和共享仪表板,并培养数据驱动的文化。

Take a look: kubernetes-metrics , metrics-server-installation .看一下: kubernetes-metricsmetrics-server-installation

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM