繁体   English   中英

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

[英]Record Kubernetes container resource utilization data

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

我一直在通过互联网挖掘寻找记录kubernetes perf的方法。 但是我找不到合适的方法来做到这一点。

专家可以请给我一个标准的方法来做到这一点吗?

注意:我也有一个多容器吊舱。

与@Jonas 评论一致

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

  1. 添加 bitnami helm repo。
helm repo add bitnami https://charts.bitnami.com/bitnami
  1. 为 promethus 安装 helmchart
helm install my-release bitnami/kube-prometheus

安装 output 将是:

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 转发到 localhost。
echo "Prometheus URL: http://127.0.0.1:9090/"
    kubectl port-forward --namespace default svc/my-release-kube-prometheus-prometheus 9090:9090
  1. 在浏览器中打开用户界面: http://127.0.0.1:9090/classic/graph

  2. 注释 pod 以发送指标。

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 中放置适当的过滤器并开始观察关键参数,例如 memory CPU 等。UI 支持自动完成,因此弄清楚事情并不难。

问候

暂无
暂无

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

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