我正在尝试根据CloudSQL实例响应时间自动扩展我的pod。我们使用cloudsql代理进行安全连接。已部署自定义度量适配器。
https://raw.githubusercontent.com/GoogleCloudPlatform/k8s-stackdriver/master/custom-metrics-stackdriver-adapter/deploy/production/adapter_new_resource_model.yaml
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: application_name
spec:
minReplicas: 1
maxReplicas: 5
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: application_name
minReplicas: 1
maxReplicas: 5
metrics:
- type: Pods
pods:
metric:
name: custom-metric-stackdriver-adapter
target:
type: AverageValue
averageValue: 20
我部署了应用程序并为此创建了HPA,但我看到了错误。
AbleToScale True SucceededGetScale the HPA controller was able to get the target's current scale
ScalingActive False FailedGetPodsMetric the HPA was unable to compute the replica count: unable to get metric custom-metric: unable to fetch metrics from custom metrics API: the server could not find the descriptor for metric custom.googleapis.com/custom-metric: googleapi: Error 404: Could not find descriptor for metric 'custom.googleapis.com/custom-metric'., notFound
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedGetPodsMetric 4m22s (x10852 over 47h) horizontal-pod-autoscaler unable to get metric custom-metric: unable to fetch metrics from custom metrics API: the server could not find the descriptor for metric custom.googleapis.com/custom-metric: googleapi: Error 404: Could not find descriptor for metric 'custom.googleapis.com/custom-metric'., notFound
- 请参阅下面的链接部署HorizontalPodAutoscaler(HPA(资源,以根据云监控指标扩展应用程序
https://cloud.google.com/kubernetes-engine/docs/tutorials/autoscaling-metrics#custom-metric_4
-
在应用程序和hpa部署配置文件(yaml(中,自定义度量名称似乎不同。应用程序和hpa部署配置文件中的度量和应用程序名称应相同。
-
在hpa部署yaml文件中,
a。将自定义公制堆叠驱动程序适配器替换为自定义公制(或更改应用程序部署yaml中自定义metric stackdriver适配器的metric名称文件(。
b。在元数据的应用程序名称旁边添加"namespace:default"。而且确保在应用程序部署配置中添加命名空间文件
c。删除重复的行6&7(最小副本数:1,最大副本数:5(。
d。转到云控制台->Kubernetes引擎->工作量。删除由应用程序部署yaml和adapter_new_resource_model.yaml文件创建的工作负载(应用程序名称和自定义度量stackdriver适配器(。
e。现在将配置应用于资源模型、应用程序和hpa(yaml文件(。