首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >记录Kubernetes容器资源利用率数据

记录Kubernetes容器资源利用率数据
EN

Stack Overflow用户
提问于 2021-04-10 19:52:41
回答 1查看 45关注 0票数 1

我正在对部署在EKS cluster上的web服务器进行性能测试。我使用不同的条件(如变化的线程数、负载大小等)使用jmeter调用服务器。所以我想用时间戳记录kubernetes性能数据,这样我就可以用我的jmeter输出(JTL)来分析这些数据。

我一直在互联网上寻找一种记录kubernetes perf数据的方法。但我找不到合适的方法来做到这一点。

专家能为我提供一种标准的方法吗?

注意:我也有一个多容器的pod。

EN

回答 1

Stack Overflow用户

发布于 2021-04-12 16:24:49

与@Jonas评论保持一致

这是在K8集群中安装Prometheus的最快方法。在答案中添加了详细信息,因为不可能将命令以可读的格式放在注释中。

  1. 添加bitnami helm存储库。

代码语言:javascript
复制
helm repo add bitnami https://charts.bitnami.com/bitnami

用于promethus的

  1. 安装帮助图表

代码语言:javascript
复制
helm install my-release bitnami/kube-prometheus

安装输出将为:

代码语言:javascript
复制
C:\Users\ameena\Desktop\shine\Article\K8\promethus>helm install my-release bitnami/kube-prometheus
NAME: my-release
LAST DEPLOYED: Mon Apr 12 12:44:13 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
** Please be patient while the chart is being deployed **

Watch the Prometheus Operator Deployment status using the command:

    kubectl get deploy -w --namespace default -l app.kubernetes.io/name=kube-prometheus-operator,app.kubernetes.io/instance=my-release

Watch the Prometheus StatefulSet status using the command:

    kubectl get sts -w --namespace default -l app.kubernetes.io/name=kube-prometheus-prometheus,app.kubernetes.io/instance=my-release

Prometheus can be accessed via port "9090" on the following DNS name from within your cluster:

    my-release-kube-prometheus-prometheus.default.svc.cluster.local

To access Prometheus from outside the cluster execute the following commands:

    echo "Prometheus URL: http://127.0.0.1:9090/"
    kubectl port-forward --namespace default svc/my-release-kube-prometheus-prometheus 9090:9090

Watch the Alertmanager StatefulSet status using the command:

    kubectl get sts -w --namespace default -l app.kubernetes.io/name=kube-prometheus-alertmanager,app.kubernetes.io/instance=my-release

Alertmanager can be accessed via port "9093" on the following DNS name from within your cluster:

    my-release-kube-prometheus-alertmanager.default.svc.cluster.local

To access Alertmanager from outside the cluster execute the following commands:

    echo "Alertmanager URL: http://127.0.0.1:9093/"
    kubectl port-forward --namespace default svc/my-release-kube-prometheus-alertmanager 9093:9093

  1. 按照命令将UI转发到本地主机。

代码语言:javascript
复制
echo "Prometheus URL: http://127.0.0.1:9090/"
    kubectl port-forward --namespace default svc/my-release-kube-prometheus-prometheus 9090:9090

在浏览器中打开UI:http://127.0.0.1:9090/classic/graph

  1. 注释用于发送指标的pods。

代码语言:javascript
复制
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 4 # Update the replicas from 2 to 4
  template:
    metadata:
      labels:
        app: nginx
      annotations:
        prometheus.io/scrape: 'true'
        prometheus.io/port: '9102'
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80

  1. 在ui中放置适当的过滤器,并开始观察关键参数,如内存、CPU等。UI支持自动完成,因此弄清楚事情不会那么困难。

问候

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67034056

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档