Kse*_*ova 5 autoscaling kubernetes
我配置了自定义指标。
当我跑步时:
kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1/namespaces/my-namespace/deployments.extensions/sample-app/queue_length" | jq
我有:
...
"items": [
{
"describedObject": {
"kind": "Deployment",
"namespace": "my-namespace",
"name": "sample-app",
"apiVersion": "extensions/v1beta1"
},
"metricName": "queue_length",
"timestamp": "2018-10-09T18:14:15Z",
"value": "30"
}
]
...
Run Code Online (Sandbox Code Playgroud)
因此,我想使用此指标扩展部署:
kind: HorizontalPodAutoscaler
apiVersion: autoscaling/v2beta1
metadata:
name: sample-app
namespace: my-namespace
spec:
scaleTargetRef:
apiVersion: extensions/v1beta1
kind: Deployment
name: sample-app
minReplicas: 1
maxReplicas: 10
metrics:
- type: Object
object:
metricName: queue_length
target:
apiVersion: extensions/v1beta1
kind: Deployment
name: sample-app
targetValue: 20
Run Code Online (Sandbox Code Playgroud)
但这似乎不起作用,也许我必须指定- type: Object
一些不同的地方。
我尝试更改kind
为Deployments,Deployments.extension,Deployments.extensions等,但是我不断收到错误消息FailedGetScale
更新:我发现HPA对象和目标对象的名称空间应该相同,因此我对其进行了更改。现在我得到了
the HPA was unable to compute the replica count: unable to get metric queue_length: Deployment on default sample-app/unable to fetch metrics from custom metrics API: the server could not find the metric queue_length for deployments.extensions sample-app
Run Code Online (Sandbox Code Playgroud)
Upd2 .:弄清楚:hpa在名称空间中default
,而metric暴露给my-namespace
。因此,应谨慎使用名称空间!
尝试这个:
---
kind: HorizontalPodAutoscaler
apiVersion: autoscaling/v2beta1
metadata:
name: sample-app
namespace: my-namespace
spec:
scaleTargetRef:
apiVersion: extensions/v1beta1
kind: Deployment
name: sample-app
minReplicas: 1
maxReplicas: 10
metrics:
- type: Object
object:
target:
kind: Service
name: sample-app
metricName: queue_length
targetValue: 20
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
230 次 |
最近记录: |