It increases/ decreases no. of replicas in deployment ( control’s no. of replicas ) based on cpu utilisation, RAM..

Horizontal Scaling : Adding more pods to cluster
Vertical Scaling : Increase size of machines ( 4 core → 8 core ). Pods will have access to more resources.
An infinite control loop constantly checks cpu utilisation in pods.
View resource usage with the Kubernetes Metrics Server - Amazon EKS
eksctl create cluster --name hpa-cluster --region ap-south-1 --nodes 3 --node-type t2.medium
kubectl apply -f <https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml>
Your cluster already had a metrics-server Deployment installed earlier (maybe via EKS addons or Helm), and kubectl apply is trying to patch it, which is failing because:
https → The Deployment manifest you applied has two container ports both named https..spec.selector after a Deployment is created. Since the one you applied differs from the existing one, it errors out.