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



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

我一直在互联网上寻找一种记录kubernetesperf数据的方法。但我找不到合适的方法。

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

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

符合@Jonas评论

这是在K8集群中安装普罗米修斯的最快方法。在答案中添加了详细信息,因为不可能在Comment中以可读的格式放置命令。

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

安装输出为:

C:UsersameenaDesktopshineArticleK8promethus>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. 在浏览器中打开UI: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中放入适当的过滤器,并开始观察关键参数,如内存CPU等。ui支持自动完成,因此解决问题不会那么困难

问候

最新更新