我正在尝试使用自动缩放方案(目前使用 microk8s 单节点个人集群)。
基本的 CPU 缩放工作正常。
对于更复杂的场景,我正在尝试遵循 https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics 上的指南。但我无法弄清楚如何/在哪里定义/记录可能的 pod 指标/对象指标。例如,.. 记录“每秒数据包数”的位置。
我可以通过 kubectl 进行导航或手动使用 REST API,但必须有更好的方法。
谢谢
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: php-apache
namespace: default
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: php-apache
minReplicas: 1
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: AverageUtilization
averageUtilization: 50
- type: Pods
pods:
metric:
name: packets-per-second ====> where is this name defined/documented ?
targetAverageValue: 1k
- type: Object
object:
metric:
name: requests-per-second ====> where is this name defined/documented ?
describedObject:
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
name: main-route
target:
kind: Value
value: 10k
最佳答案
ResourceMetric 中的 CPU 或内存使用情况是 provided by kubelet并由 metric-server 收集
但是对于 packets-per-second
和 requests-per-second
,没有官方提供者,因此该字段实际上可以是任何值,具体取决于您部署的非官方自定义指标 API。
一些流行的自定义指标 API 列于 https://github.com/kubernetes/metrics/blob/master/IMPLEMENTATIONS.md
关于kubernetes - kubernetes 自动缩放的可能指标在哪里定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57330661/