We are Borg
We are Borg

Reputation: 5313

Kubernetes HPA : Send HPA logs as events to aws cloudwatch

I am working on EKS cluster in AWS. We have an application, which is memory intensive. Because of that, I have added an HPA, which has 60% memory utilization. We would like to have only this info in cloudwatch, so we can scale our servers accordingly. I tried container insights, but it's an overkill.

Is there any way to get Kubernetes HPA logs in cloudwatch as events?

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

Versions :

 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 cluster is running on 1.15

Upvotes: 1

Views: 1770

Answers (1)

Vit
Vit

Reputation: 8481

I believe you can use k8s-cloudwatch-adapter for your needs. Scaling Kubernetes deployments with Amazon CloudWatch metrics documentation provides the info on how k8s-cloudwatch-adapter works, how you can install and use it.

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

Please also look into Kubernetes AWS Cloudwatch adapter not fetching custom metric value for EKS HPA autoscaling - already good example on how to enable AWS EKS autoscaling based on a custom Cloudwatch metric

Upvotes: 1

Related Questions