How do I set up Kubernetes Metrics Server and Horizontal Pod Autoscaler on Amazon EKS?
I want to set up Kubernetes Metrics Server and Horizontal Pod Autoscaler (HPA) on Amazon Elastic Kubernetes Service (Amazon EKS).
"I want to set up Kubernetes Metrics Server and Horizontal Pod Autoscaler (HPA) on Amazon Elastic Kubernetes Service (Amazon EKS).ResolutionSet up your environment1.    Create an Amazon Elastic Compute Cloud (Amazon EC2) instance.2.    Install kubectl on your EC2 instance.3.    Install and configure the latest version of the AWS Command Line Interface (AWS CLI) on your EC2 instance.4.    Configure your kubeconfig file to point to the Amazon EKS cluster.Create a Kubernetes Metrics Server1.    To install Metrics Server, run the following command:kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml2.    To confirm that Metrics Server is running, run the following command:kubectl get pods -n kube-system -l k8s-app=metrics-serverThe output is similar to the following:kubectl get pods -n kube-system -l k8s-app=metrics-servermetrics-server-85cc795fbf-79d72   1/1     Running   0          22sCreate a php-apache deployment and a service1.    To create a php-apache deployment, run the following command:kubectl create deployment php-apache --image=k8s.gcr.io/hpa-example2.    To set the CPU requests, run the following command:kubectl patch deployment php-apache -p='{"spec":{"template":{"spec":{"containers":[{"name":"hpa-example","resources":{"requests":{"cpu":"200m"}}}]}}}}'Important: If you don't set the value for cpu correctly, then the CPU utilization metric for the pod isn't defined and the HPA can't scale.3.    To expose the deployment as a service, run the following command:kubectl create service clusterip php-apache --tcp=804.    To create an HPA, run the following command:kubectl autoscale deployment php-apache --cpu-percent=50 --min=1 --max=105.    To confirm that the HPA was created, run the following command:kubectl get hpa6.    To create a pod to connect to the deployment that you created earlier, run the following command:kubectl run -i --tty load-generator --image=busybox /bin/sh7.    To test a load on the pod in the namespace that you used in step 1, run the following script:while true; do wget -q -O- http://php-apache; doneNote: To exit the while loop and the tty session of the load generator pod, use CTRL + C to cancel the loop. Then, use CTRL + D to exit the session.8.    To see how the HPA scales the pod based on CPU utilization metrics, run the following command (preferably from another terminal window):kubectl get hpa -wThe Metrics Server is now up and running, and you can use it to get resource-based metrics.9.    To clean up the resources used for testing the HPA, run the following commands:kubectl delete hpa,service,deployment php-apachekubectl delete pod load-generatorRelated informationHorizontal Pod AutoscalingFollow"