Java Spring Boot Kubernetes:水平 pod 自动缩放器
Java SpringBoot Kubernetes: horizontal pod autoscale
请问如何实现水平pod自动缩放的小问题
我有一个在 Kubernetes 中部署了 Actuator/Micrometer/Prometheus 插件的 SpringBoot 应用程序
因此,非常高兴,我在向应用程序查询时看到了我的指标
curl http://my-service.com/prometheus
http_server_requests_seconds_count{application="my-service",exception="None",method="POST",outcome="SUCCESS",status="200",uri="/myRoute",} 1.0
并且还看到了位于 X 位置的普罗米修斯服务器中的时间序列,看到了图表。很开心,到目前为止一切顺利。
但是,当我想要自动缩放时,什么也没有发生。
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: my-service
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: my-service
maxReplicas: 3
minReplicas: 1
metrics:
- type: Pods
pods:
metricName: http_server_requests_seconds_count
targetAverageValue: "5"
请问为什么?
我的第一个想法是,我什至不确定 Kubernetes 是否知道我们的 Prometheus 服务器在位置 X 的下落。
我无法理解两者如何协同工作。
请问如何根据位于 X 位置的 Prometheus 中可用的 SpringBoot 指标(请求计数)从 Kubernetes 实现 HPA?
谢谢
Kubernetes 中的自定义指标需要进一步集成才能发挥作用。
一般来说,如果你使用prometheus的自定义指标,你可以在此处使用prometheus适配器将prometheus服务器连接到Kubernetes中的实际自定义指标,https://github.com/DirectXMan12/k8s-prometheus-adapter。
您可以通过 helm 安装它并将其连接到您的 prometheus 服务器。成功设置后,您可以通过以下命令获取自定义指标,具体取决于您的 Kubernetes 版本。
kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1"
最终,当您使用 kubectl 描述 HPA 时,您将看到 HPA 对象中显示的指标。
请问如何实现水平pod自动缩放的小问题
我有一个在 Kubernetes 中部署了 Actuator/Micrometer/Prometheus 插件的 SpringBoot 应用程序
因此,非常高兴,我在向应用程序查询时看到了我的指标
curl http://my-service.com/prometheus
http_server_requests_seconds_count{application="my-service",exception="None",method="POST",outcome="SUCCESS",status="200",uri="/myRoute",} 1.0
并且还看到了位于 X 位置的普罗米修斯服务器中的时间序列,看到了图表。很开心,到目前为止一切顺利。
但是,当我想要自动缩放时,什么也没有发生。
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: my-service
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: my-service
maxReplicas: 3
minReplicas: 1
metrics:
- type: Pods
pods:
metricName: http_server_requests_seconds_count
targetAverageValue: "5"
请问为什么?
我的第一个想法是,我什至不确定 Kubernetes 是否知道我们的 Prometheus 服务器在位置 X 的下落。
我无法理解两者如何协同工作。
请问如何根据位于 X 位置的 Prometheus 中可用的 SpringBoot 指标(请求计数)从 Kubernetes 实现 HPA?
谢谢
Kubernetes 中的自定义指标需要进一步集成才能发挥作用。
一般来说,如果你使用prometheus的自定义指标,你可以在此处使用prometheus适配器将prometheus服务器连接到Kubernetes中的实际自定义指标,https://github.com/DirectXMan12/k8s-prometheus-adapter。
您可以通过 helm 安装它并将其连接到您的 prometheus 服务器。成功设置后,您可以通过以下命令获取自定义指标,具体取决于您的 Kubernetes 版本。
kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1"
最终,当您使用 kubectl 描述 HPA 时,您将看到 HPA 对象中显示的指标。