乐趣区

k8s与HPA–通过 Prometheus adaptor 来自定义监控指标

k8s 与 HPA– 通过 Prometheus adaptor 来自定义监控指标
自动扩展是一种根据资源使用情况自动扩展或缩小工作负载的方法。Kubernetes 中的自动缩放有两个维度:Cluster Autoscaler 处理节点扩展操作,Horizo​​ntal Pod Autoscaler 自动扩展部署或副本集中的 pod 数量。Cluster Autoscaling 与 Horizo​​ntal Pod Autoscaler 一起用于动态调整计算能力以及系统满足 SLA 所需的并行度。虽然 Cluster Autoscaler 高度依赖托管您的集群的云提供商的基础功能,但 HPA 可以独立于您的 IaaS / PaaS 提供商运营。
Horizo​​ntal Pod Autoscaler 功能最初是在 Kubernetes v1.1 中引入的,并且从那时起已经发展了很多。HPA 缩放容器的版本 1 基于观察到的 CPU 利用率,后来基于内存使用情况。在 Kubernetes 1.6 中,引入了一个新的 API Custom Metrics API,使 HPA 能够访问任意指标。Kubernetes 1.7 引入了聚合层,允许第三方应用程序通过将自己注册为 API 附加组件来扩展 Kubernetes API。Custom Metrics API 和聚合层使 Prometheus 等监控系统可以向 HPA 控制器公开特定于应用程序的指标。
Horizo​​ntal Pod Autoscaler 实现为一个控制循环,定期查询 Resource Metrics API 以获取 CPU / 内存等核心指标和针对特定应用程序指标的 Custom Metrics API。

以下是为 Kubernetes 1.9 或更高版本配置 HPA v2 的分步指南。您将安装提供核心指标的 Metrics Server 附加组件,然后您将使用演示应用程序根据 CPU 和内存使用情况展示 pod 自动扩展。在本指南的第二部分中,您将部署 Prometheus 和自定义 API 服务器。您将使用聚合器层注册自定义 API 服务器,然后使用演示应用程序提供的自定义指标配置 HPA。
在开始之前,您需要安装 Go 1.8 或更高版本并在 GOPATH 中克隆 k8s-prom-hpa repo。
cd $GOPATH
git clone https://github.com/stefanprodan/k8s-prom-hpa
部署 Metrics Server
kubernetes Metrics Server 是资源使用数据的集群范围聚合器,是 Heapster 的后继者。度量服务器通过汇集来自 kubernetes.summary_api 的数据来收集节点和 pod 的 CPU 和内存使用情况。摘要 API 是一种内存高效的 API,用于将数据从 Kubelet / cAdvisor 传递到度量服务器。

在 HPA 的第一个版本中,您需要 Heapster 来提供 CPU 和内存指标,在 HPA v2 和 Kubernetes 1.8 中,只有在启用 horizo​​ntal-pod-autoscaler-use-rest-clients 时才需要指标服务器。默认情况下,Kubernetes 1.9 中启用了 HPA rest 客户端。GKE 1.9 附带预安装的 Metrics Server。
在 kube-system 命名空间中部署 Metrics Server:
kubectl create -f ./metrics-server
一分钟后,度量服务器开始报告节点和 pod 的 CPU 和内存使用情况。
查看 nodes metrics:
kubectl get –raw “/apis/metrics.k8s.io/v1beta1/nodes” | jq .
结果如下:
{
“kind”: “NodeMetricsList”,
“apiVersion”: “metrics.k8s.io/v1beta1”,
“metadata”: {
“selfLink”: “/apis/metrics.k8s.io/v1beta1/nodes”
},
“items”: [
{
“metadata”: {
“name”: “ip-10-1-50-61.ec2.internal”,
“selfLink”: “/apis/metrics.k8s.io/v1beta1/nodes/ip-10-1-50-61.ec2.internal”,
“creationTimestamp”: “2019-02-13T08:34:05Z”
},
“timestamp”: “2019-02-13T08:33:38Z”,
“window”: “30s”,
“usage”: {
“cpu”: “78322168n”,
“memory”: “563180Ki”
}
},
{
“metadata”: {
“name”: “ip-10-1-57-40.ec2.internal”,
“selfLink”: “/apis/metrics.k8s.io/v1beta1/nodes/ip-10-1-57-40.ec2.internal”,
“creationTimestamp”: “2019-02-13T08:34:05Z”
},
“timestamp”: “2019-02-13T08:33:42Z”,
“window”: “30s”,
“usage”: {
“cpu”: “48926263n”,
“memory”: “554472Ki”
}
},
{
“metadata”: {
“name”: “ip-10-1-62-29.ec2.internal”,
“selfLink”: “/apis/metrics.k8s.io/v1beta1/nodes/ip-10-1-62-29.ec2.internal”,
“creationTimestamp”: “2019-02-13T08:34:05Z”
},
“timestamp”: “2019-02-13T08:33:36Z”,
“window”: “30s”,
“usage”: {
“cpu”: “36700681n”,
“memory”: “326088Ki”
}
}
]
}
查看 pods metrics:
kubectl get –raw “/apis/metrics.k8s.io/v1beta1/pods” | jq .
结果如下:
{
“kind”: “PodMetricsList”,
“apiVersion”: “metrics.k8s.io/v1beta1”,
“metadata”: {
“selfLink”: “/apis/metrics.k8s.io/v1beta1/pods”
},
“items”: [
{
“metadata”: {
“name”: “kube-proxy-77nt2”,
“namespace”: “kube-system”,
“selfLink”: “/apis/metrics.k8s.io/v1beta1/namespaces/kube-system/pods/kube-proxy-77nt2”,
“creationTimestamp”: “2019-02-13T08:35:19Z”
},
“timestamp”: “2019-02-13T08:35:00Z”,
“window”: “30s”,
“containers”: [
{
“name”: “kube-proxy”,
“usage”: {
“cpu”: “2370555n”,
“memory”: “13184Ki”
}
}
]
},
{
“metadata”: {
“name”: “cluster-autoscaler-n2xsl”,
“namespace”: “kube-system”,
“selfLink”: “/apis/metrics.k8s.io/v1beta1/namespaces/kube-system/pods/cluster-autoscaler-n2xsl”,
“creationTimestamp”: “2019-02-13T08:35:19Z”
},
“timestamp”: “2019-02-13T08:35:12Z”,
“window”: “30s”,
“containers”: [
{
“name”: “cluster-autoscaler”,
“usage”: {
“cpu”: “1477997n”,
“memory”: “54584Ki”
}
}
]
},
{
“metadata”: {
“name”: “core-dns-autoscaler-b4785d4d7-j64xd”,
“namespace”: “kube-system”,
“selfLink”: “/apis/metrics.k8s.io/v1beta1/namespaces/kube-system/pods/core-dns-autoscaler-b4785d4d7-j64xd”,
“creationTimestamp”: “2019-02-13T08:35:19Z”
},
“timestamp”: “2019-02-13T08:35:08Z”,
“window”: “30s”,
“containers”: [
{
“name”: “autoscaler”,
“usage”: {
“cpu”: “191293n”,
“memory”: “7956Ki”
}
}
]
},
{
“metadata”: {
“name”: “spot-interrupt-handler-8t2xk”,
“namespace”: “kube-system”,
“selfLink”: “/apis/metrics.k8s.io/v1beta1/namespaces/kube-system/pods/spot-interrupt-handler-8t2xk”,
“creationTimestamp”: “2019-02-13T08:35:19Z”
},
“timestamp”: “2019-02-13T08:35:04Z”,
“window”: “30s”,
“containers”: [
{
“name”: “spot-interrupt-handler”,
“usage”: {
“cpu”: “844907n”,
“memory”: “4608Ki”
}
}
]
},
{
“metadata”: {
“name”: “kube-proxy-t5kqm”,
“namespace”: “kube-system”,
“selfLink”: “/apis/metrics.k8s.io/v1beta1/namespaces/kube-system/pods/kube-proxy-t5kqm”,
“creationTimestamp”: “2019-02-13T08:35:19Z”
},
“timestamp”: “2019-02-13T08:35:08Z”,
“window”: “30s”,
“containers”: [
{
“name”: “kube-proxy”,
“usage”: {
“cpu”: “1194766n”,
“memory”: “12204Ki”
}
}
]
},
{
“metadata”: {
“name”: “kube-proxy-zxmqb”,
“namespace”: “kube-system”,
“selfLink”: “/apis/metrics.k8s.io/v1beta1/namespaces/kube-system/pods/kube-proxy-zxmqb”,
“creationTimestamp”: “2019-02-13T08:35:19Z”
},
“timestamp”: “2019-02-13T08:35:06Z”,
“window”: “30s”,
“containers”: [
{
“name”: “kube-proxy”,
“usage”: {
“cpu”: “3021117n”,
“memory”: “13628Ki”
}
}
]
},
{
“metadata”: {
“name”: “aws-node-rcz5c”,
“namespace”: “kube-system”,
“selfLink”: “/apis/metrics.k8s.io/v1beta1/namespaces/kube-system/pods/aws-node-rcz5c”,
“creationTimestamp”: “2019-02-13T08:35:19Z”
},
“timestamp”: “2019-02-13T08:35:15Z”,
“window”: “30s”,
“containers”: [
{
“name”: “aws-node”,
“usage”: {
“cpu”: “1217989n”,
“memory”: “24976Ki”
}
}
]
},
{
“metadata”: {
“name”: “aws-node-z2qxs”,
“namespace”: “kube-system”,
“selfLink”: “/apis/metrics.k8s.io/v1beta1/namespaces/kube-system/pods/aws-node-z2qxs”,
“creationTimestamp”: “2019-02-13T08:35:19Z”
},
“timestamp”: “2019-02-13T08:35:15Z”,
“window”: “30s”,
“containers”: [
{
“name”: “aws-node”,
“usage”: {
“cpu”: “1025780n”,
“memory”: “46424Ki”
}
}
]
},
{
“metadata”: {
“name”: “php-apache-899d75b96-8ppk4”,
“namespace”: “default”,
“selfLink”: “/apis/metrics.k8s.io/v1beta1/namespaces/default/pods/php-apache-899d75b96-8ppk4”,
“creationTimestamp”: “2019-02-13T08:35:19Z”
},
“timestamp”: “2019-02-13T08:35:08Z”,
“window”: “30s”,
“containers”: [
{
“name”: “php-apache”,
“usage”: {
“cpu”: “24612n”,
“memory”: “27556Ki”
}
}
]
},
{
“metadata”: {
“name”: “load-generator-779c5f458c-9sglg”,
“namespace”: “default”,
“selfLink”: “/apis/metrics.k8s.io/v1beta1/namespaces/default/pods/load-generator-779c5f458c-9sglg”,
“creationTimestamp”: “2019-02-13T08:35:19Z”
},
“timestamp”: “2019-02-13T08:34:56Z”,
“window”: “30s”,
“containers”: [
{
“name”: “load-generator”,
“usage”: {
“cpu”: “0”,
“memory”: “336Ki”
}
}
]
},
{
“metadata”: {
“name”: “aws-node-v9jxs”,
“namespace”: “kube-system”,
“selfLink”: “/apis/metrics.k8s.io/v1beta1/namespaces/kube-system/pods/aws-node-v9jxs”,
“creationTimestamp”: “2019-02-13T08:35:19Z”
},
“timestamp”: “2019-02-13T08:35:00Z”,
“window”: “30s”,
“containers”: [
{
“name”: “aws-node”,
“usage”: {
“cpu”: “1303458n”,
“memory”: “28020Ki”
}
}
]
},
{
“metadata”: {
“name”: “kube2iam-m2ktt”,
“namespace”: “kube-system”,
“selfLink”: “/apis/metrics.k8s.io/v1beta1/namespaces/kube-system/pods/kube2iam-m2ktt”,
“creationTimestamp”: “2019-02-13T08:35:19Z”
},
“timestamp”: “2019-02-13T08:35:11Z”,
“window”: “30s”,
“containers”: [
{
“name”: “kube2iam”,
“usage”: {
“cpu”: “1328864n”,
“memory”: “9724Ki”
}
}
]
},
{
“metadata”: {
“name”: “kube2iam-w9cqf”,
“namespace”: “kube-system”,
“selfLink”: “/apis/metrics.k8s.io/v1beta1/namespaces/kube-system/pods/kube2iam-w9cqf”,
“creationTimestamp”: “2019-02-13T08:35:19Z”
},
“timestamp”: “2019-02-13T08:35:03Z”,
“window”: “30s”,
“containers”: [
{
“name”: “kube2iam”,
“usage”: {
“cpu”: “1294379n”,
“memory”: “8812Ki”
}
}
]
},
{
“metadata”: {
“name”: “custom-metrics-apiserver-657644489c-pk8rb”,
“namespace”: “monitoring”,
“selfLink”: “/apis/metrics.k8s.io/v1beta1/namespaces/monitoring/pods/custom-metrics-apiserver-657644489c-pk8rb”,
“creationTimestamp”: “2019-02-13T08:35:19Z”
},
“timestamp”: “2019-02-13T08:35:04Z”,
“window”: “30s”,
“containers”: [
{
“name”: “custom-metrics-apiserver”,
“usage”: {
“cpu”: “22409370n”,
“memory”: “42468Ki”
}
}
]
},
{
“metadata”: {
“name”: “kube2iam-qghgt”,
“namespace”: “kube-system”,
“selfLink”: “/apis/metrics.k8s.io/v1beta1/namespaces/kube-system/pods/kube2iam-qghgt”,
“creationTimestamp”: “2019-02-13T08:35:19Z”
},
“timestamp”: “2019-02-13T08:35:11Z”,
“window”: “30s”,
“containers”: [
{
“name”: “kube2iam”,
“usage”: {
“cpu”: “2078992n”,
“memory”: “16356Ki”
}
}
]
},
{
“metadata”: {
“name”: “spot-interrupt-handler-ps745”,
“namespace”: “kube-system”,
“selfLink”: “/apis/metrics.k8s.io/v1beta1/namespaces/kube-system/pods/spot-interrupt-handler-ps745”,
“creationTimestamp”: “2019-02-13T08:35:19Z”
},
“timestamp”: “2019-02-13T08:35:10Z”,
“window”: “30s”,
“containers”: [
{
“name”: “spot-interrupt-handler”,
“usage”: {
“cpu”: “611566n”,
“memory”: “4336Ki”
}
}
]
},
{
“metadata”: {
“name”: “coredns-68fb7946fb-2xnpp”,
“namespace”: “kube-system”,
“selfLink”: “/apis/metrics.k8s.io/v1beta1/namespaces/kube-system/pods/coredns-68fb7946fb-2xnpp”,
“creationTimestamp”: “2019-02-13T08:35:19Z”
},
“timestamp”: “2019-02-13T08:35:12Z”,
“window”: “30s”,
“containers”: [
{
“name”: “coredns”,
“usage”: {
“cpu”: “1610381n”,
“memory”: “10480Ki”
}
}
]
},
{
“metadata”: {
“name”: “coredns-68fb7946fb-9ctjf”,
“namespace”: “kube-system”,
“selfLink”: “/apis/metrics.k8s.io/v1beta1/namespaces/kube-system/pods/coredns-68fb7946fb-9ctjf”,
“creationTimestamp”: “2019-02-13T08:35:19Z”
},
“timestamp”: “2019-02-13T08:35:13Z”,
“window”: “30s”,
“containers”: [
{
“name”: “coredns”,
“usage”: {
“cpu”: “1418850n”,
“memory”: “9852Ki”
}
}
]
},
{
“metadata”: {
“name”: “prometheus-7d4f6d4454-v4fnd”,
“namespace”: “monitoring”,
“selfLink”: “/apis/metrics.k8s.io/v1beta1/namespaces/monitoring/pods/prometheus-7d4f6d4454-v4fnd”,
“creationTimestamp”: “2019-02-13T08:35:19Z”
},
“timestamp”: “2019-02-13T08:35:00Z”,
“window”: “30s”,
“containers”: [
{
“name”: “prometheus”,
“usage”: {
“cpu”: “17951807n”,
“memory”: “202316Ki”
}
}
]
},
{
“metadata”: {
“name”: “metrics-server-7cdd54ccb4-k2x7m”,
“namespace”: “kube-system”,
“selfLink”: “/apis/metrics.k8s.io/v1beta1/namespaces/kube-system/pods/metrics-server-7cdd54ccb4-k2x7m”,
“creationTimestamp”: “2019-02-13T08:35:19Z”
},
“timestamp”: “2019-02-13T08:35:04Z”,
“window”: “30s”,
“containers”: [
{
“name”: “metrics-server-nanny”,
“usage”: {
“cpu”: “144656n”,
“memory”: “5716Ki”
}
},
{
“name”: “metrics-server”,
“usage”: {
“cpu”: “568327n”,
“memory”: “16268Ki”
}
}
]
}
]
}
基于 CPU 和内存使用情况的 Auto Scaling
您将使用基于 Golang 的小型 Web 应用程序来测试 Horizo​​ntal Pod Autoscaler(HPA)。
将 podinfo 部署到默认命名空间:
kubectl create -f ./podinfo/podinfo-svc.yaml,./podinfo/podinfo-dep.yaml
使用 NodePort 服务访问 podinfo,地址为 http:// <K8S_PUBLIC_IP>:31198。
接下来定义一个至少维护两个副本的 HPA,如果 CPU 平均值超过 80%或内存超过 200Mi,则最多可扩展到 10 个:
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: podinfo
spec:
scaleTargetRef:
apiVersion: extensions/v1beta1
kind: Deployment
name: podinfo
minReplicas: 2
maxReplicas: 10
metrics:
– type: Resource
resource:
name: cpu
targetAverageUtilization: 80
– type: Resource
resource:
name: memory
targetAverageValue: 200Mi
创建这个 hpa:
kubectl create -f ./podinfo/podinfo-hpa.yaml
几秒钟后,HPA 控制器联系度量服务器,然后获取 CPU 和内存使用情况:
kubectl get hpa

NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
podinfo Deployment/podinfo 2826240 / 200Mi, 15% / 80% 2 10 2 5m
为了增加 CPU 使用率,请使用 rakyll / hey 运行负载测试:
#install hey
go get -u github.com/rakyll/hey

#do 10K requests
hey -n 10000 -q 10 -c 5 http://<K8S_PUBLIC_IP>:31198/
您可以使用以下方式监控 HPA 事件:
$ kubectl describe hpa

Events:
Type Reason Age From Message
—- —— —- —- ——-
Normal SuccessfulRescale 7m horizontal-pod-autoscaler New size: 4; reason: cpu resource utilization (percentage of request) above target
Normal SuccessfulRescale 3m horizontal-pod-autoscaler New size: 8; reason: cpu resource utilization (percentage of request) above target
暂时删除 podinfo。稍后将在本教程中再次部署它:
kubectl delete -f ./podinfo/podinfo-hpa.yaml,./podinfo/podinfo-dep.yaml,./podinfo/podinfo-svc.yaml
部署 Custom Metrics Server
要根据自定义指标进行扩展,您需要拥有两个组件。一个组件,用于从应用程序收集指标并将其存储在 Prometheus 时间序列数据库中。第二个组件使用 collect(k8s-prometheus-adapter)提供的指标扩展了 Kubernetes 自定义指标 API。

您将在专用命名空间中部署 Prometheus 和适配器。
创建 monitoring 命名空间:
kubectl create -f ./namespaces.yaml
在 monitoring 命名空间中部署 Prometheus v2:
kubectl create -f ./prometheus
生成 Prometheus 适配器所需的 TLS 证书:
make certs
生成以下几个文件:
# ls output
apiserver.csr apiserver-key.pem apiserver.pem
部署 Prometheus 自定义指标 API 适配器:
kubectl create -f ./custom-metrics-api

列出 Prometheus 提供的自定义指标:
kubectl get –raw “/apis/custom.metrics.k8s.io/v1beta1” | jq .
获取 monitoring 命名空间中所有 pod 的 FS 使用情况:
kubectl get –raw “/apis/custom.metrics.k8s.io/v1beta1/namespaces/monitoring/pods/*/fs_usage_bytes” | jq .
查询结果如下:

{
“kind”: “MetricValueList”,
“apiVersion”: “custom.metrics.k8s.io/v1beta1”,
“metadata”: {
“selfLink”: “/apis/custom.metrics.k8s.io/v1beta1/namespaces/monitoring/pods/%2A/fs_usage_bytes”
},
“items”: [
{
“describedObject”: {
“kind”: “Pod”,
“namespace”: “monitoring”,
“name”: “custom-metrics-apiserver-657644489c-pk8rb”,
“apiVersion”: “/v1”
},
“metricName”: “fs_usage_bytes”,
“timestamp”: “2019-02-13T08:52:30Z”,
“value”: “94253056”
},
{
“describedObject”: {
“kind”: “Pod”,
“namespace”: “monitoring”,
“name”: “prometheus-7d4f6d4454-v4fnd”,
“apiVersion”: “/v1”
},
“metricName”: “fs_usage_bytes”,
“timestamp”: “2019-02-13T08:52:30Z”,
“value”: “24576”
}
]
}
基于 custom metrics 自动伸缩
在默认命名空间中创建 podinfo NodePort 服务和部署:
kubectl create -f ./podinfo/podinfo-svc.yaml,./podinfo/podinfo-dep.yaml
podinfo 应用程序公开名为 http_requests_total 的自定义指标。Prometheus 适配器删除_total 后缀并将度量标记为计数器度量标准。
从自定义指标 API 获取每秒的总请求数:
kubectl get –raw “/apis/custom.metrics.k8s.io/v1beta1/namespaces/default/pods/*/http_requests” | jq .
{
“kind”: “MetricValueList”,
“apiVersion”: “custom.metrics.k8s.io/v1beta1”,
“metadata”: {
“selfLink”: “/apis/custom.metrics.k8s.io/v1beta1/namespaces/default/pods/%2A/http_requests”
},
“items”: [
{
“describedObject”: {
“kind”: “Pod”,
“namespace”: “default”,
“name”: “podinfo-6b86c8ccc9-kv5g9”,
“apiVersion”: “/__internal”
},
“metricName”: “http_requests”,
“timestamp”: “2018-01-10T16:49:07Z”,
“value”: “901m”
},
{
“describedObject”: {
“kind”: “Pod”,
“namespace”: “default”,
“name”: “podinfo-6b86c8ccc9-nm7bl”,
“apiVersion”: “/__internal”
},
“metricName”: “http_requests”,
“timestamp”: “2018-01-10T16:49:07Z”,
“value”: “898m”
}
]
}

建一个 HPA,如果请求数超过每秒 10 个,将扩展 podinfo 部署:
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: podinfo
spec:
scaleTargetRef:
apiVersion: extensions/v1beta1
kind: Deployment
name: podinfo
minReplicas: 2
maxReplicas: 10
metrics:
– type: Pods
pods:
metricName: http_requests
targetAverageValue: 10

在默认命名空间中部署 podinfo HPA:
kubectl create -f ./podinfo/podinfo-hpa-custom.yaml

几秒钟后,HPA 从指标 API 获取 http_requests 值:
kubectl get hpa

NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
podinfo Deployment/podinfo 899m / 10 2 10 2 1m

在 podinfo 服务上应用一些负载,每秒 25 个请求:
#install hey
go get -u github.com/rakyll/hey

#do 10K requests rate limited at 25 QPS
hey -n 10000 -q 5 -c 5 http://<K8S-IP>:31198/healthz

几分钟后,HPA 开始扩展部署:
kubectl describe hpa

Name: podinfo
Namespace: default
Reference: Deployment/podinfo
Metrics: (current / target)
“http_requests” on pods: 9059m / 10
Min replicas: 2
Max replicas: 10

Events:
Type Reason Age From Message
—- —— —- —- ——-
Normal SuccessfulRescale 2m horizontal-pod-autoscaler New size: 3; reason: pods metric http_requests above target

按照当前的每秒请求速率,部署永远不会达到 10 个 pod 的最大值。三个复制品足以使每个吊舱的 RPS 保持在 10 以下。
负载测试完成后,HPA 会将部署缩到其初始副本:
Events:
Type Reason Age From Message
—- —— —- —- ——-
Normal SuccessfulRescale 5m horizontal-pod-autoscaler New size: 3; reason: pods metric http_requests above target
Normal SuccessfulRescale 21s horizontal-pod-autoscaler New size: 2; reason: All metrics below target

您可能已经注意到自动缩放器不会立即对使用峰值做出反应。默认情况下,度量标准同步每 30 秒发生一次,只有在最后 3 - 5 分钟内没有重新缩放时才能进行扩展 / 缩小。通过这种方式,HPA 可以防止快速执行冲突的决策,并为 Cluster Autoscaler 提供时间。
结论
并非所有系统都可以通过单独依赖 CPU / 内存使用指标来满足其 SLA,大多数 Web 和移动后端需要基于每秒请求进行自动扩展以处理任何流量突发。对于 ETL 应用程序,可以通过作业队列长度超过某个阈值等来触发自动缩放。通过使用 Prometheus 检测应用程序并公开正确的自动缩放指标,您可以对应用程序进行微调,以更好地处理突发并确保高可用性。

退出移动版