Kubernetes HPA:将 HPA 日志作为事件发送到 aws cloudwatch

Kubernetes HPA : Send HPA logs as events to aws cloudwatch

我正在 AWS 的 EKS 集群上工作。我们有一个内存密集型应用程序。因此,我添加了一个 HPA,它的内存利用率为 60%。我们希望在 cloudwatch 中只有这些信息,因此我们可以相应地扩展我们的服务器。我尝试了 container insights,但它有点矫枉过正。

有什么方法可以让 Kubernetes HPA 日志作为事件记录在 cloudwatch 中吗?

HPA :

apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
  name: resize-hpa
spec:
  scaleTargetRef:
    apiVersion: apps/v1beta1
    kind: Deployment
    name: magento-prod-deployment
  minReplicas: 2
  maxReplicas: 5
  metrics:
  - type: Resource
    resource:
      name: memory 
      target:
        type: Utilization 
        averageUtilization: 60

版本:

 kubectl version
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.8", GitCommit:"9f2892aab98fe339f3bd70e3c470144299398ace", GitTreeState:"clean", BuildDate:"2020-08-26T20:32:49Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"15+", GitVersion:"v1.15.11-eks-065dce", GitCommit:"065dcecfcd2a91bd68a17ee0b5e895088430bd05", GitTreeState:"clean", BuildDate:"2020-07-16T01:44:47Z", GoVersion:"go1.12.17", Compiler:"gc", Platform:"linux/amd64"}

EKS 集群在 1.15

上 运行

我相信您可以使用 k8s-cloudwatch-adapter 来满足您的需求。 Scaling Kubernetes deployments with Amazon CloudWatch metrics 文档提供了有关 k8s-cloudwatch-adapter 工作原理、安装和使用方法的信息。

Amazon CloudWatch Metrics Adapter for Kubernetes

The k8s-cloudwatch-adapter is an implementation of the Kubernetes Custom Metrics API and External Metrics API with integration for CloudWatch metrics. It allows you to scale your Kubernetes deployment using the Horizontal Pod Autoscaler (HPA) with CloudWatch metrics.

k8s-cloudwatch-adapter github

另请查看 - 关于如何根据自定义 Cloudwatch 指标启用 AWS EKS 自动缩放的很好示例