Yash Gurav
Yash Gurav

Reputation: 33

How to autoscale Kubernetes Pods based on average memory usage in EKS?

I am running an EKS cluster and I have a HorizontalPodAutoscaler created for autoscaling number of pods based on average CPU utilisation.

How to do the same for Average memory utilization?

Suppose all of the pods running in an EKS clusters, have used average of 70% of memory they are allocated (using resources), then the deployment should be autoscaled.

How to do this? Is creating a custom metric in CloudWatch the only way?

Even if cloudWatch is the only way, how to do that? Is there a specific documentation or tutorial or blog that does this?

Upvotes: 3

Views: 1368

Answers (1)

nischay goyal
nischay goyal

Reputation: 3480

Please try the below HPA configuration object.

apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
  name: nginx-hpa
  namespace: default
spec:
  scaleTargetRef:
    apiVersion: extensions/v1beta1
    kind: Deployment
    name: nginx
  minReplicas: 2
  maxReplicas: 10
  metrics:
  - type: Resource
    resource:
      name: memory
      targetAverageUtilization: 70

and apply the object using kubectl apply

Upvotes: 2

Related Questions