【问题标题】:Kubernetes HPA : Send HPA logs as events to aws cloudwatchKubernetes HPA:将 HPA 日志作为事件发送到 aws cloudwatch
【发布时间】:2021-01-11 14:29:35
【问题描述】:

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

有什么方法可以在 cloudwatch 中获取 Kubernetes HPA 日志作为事件?

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 上运行

【问题讨论】:

    标签: amazon-web-services kubernetes amazon-cloudwatch amazon-eks horizontal-pod-autoscaling


    【解决方案1】:

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

    适用于 Kubernetes 的 Amazon CloudWatch 指标适配器

    k8s-cloudwatch-adapter 是 Kubernetes 的一个实现 自定义指标 API 和外部指标 API 与集成 CloudWatch 指标。它允许您扩展 Kubernetes 部署 将 Horizo​​ntal Pod Autoscaler (HPA) 与 CloudWatch 指标结合使用。

    k8s-cloudwatch-adapter github

    还请查看Kubernetes AWS Cloudwatch adapter not fetching custom metric value for EKS HPA autoscaling - 关于如何基于自定义 Cloudwatch 指标启用 AWS EKS 自动缩放的很好示例

    【讨论】:

    猜你喜欢
    • 2018-03-10
    • 2021-09-07
    • 2020-01-25
    • 2020-10-23
    • 1970-01-01
    • 2020-04-16
    • 2020-03-07
    • 2018-06-27
    • 2020-09-27
    相关资源
    最近更新 更多