The vfarcic/k8s-specs (https://github.com/vfarcic/k8s-specs) repository will continue to serve as our source of Kubernetes definitions. We'll make sure that it is up-to-date by pulling the latest version.
All the commands from this chapter are available in the 05-hpa-custom-metrics.sh (https://gist.github.com/vfarcic/cc546f81e060e4f5fc5661e4fa003af7) Gist.
1 cd k8s-specs 2 3 git pull
The requirements are the same as those we had in the previous chapter. The only exception is EKS. We'll continue using the same Gists as before for all other Kuberentes flavors.
A note to EKS users
Even though three t2.small nodes we used so far have more than enough memory and CPU, they might not be able to host all the Pods we'll create. EKS (by default) uses AWS networking. A t2.small instance can have a maximum of three network interfaces, with four IPv4 address per each. That means that we can have up to twelve IPv4 addresses on each t2.small node. Given that each Pod needs to have its own address, that means that we can have a maximum of twelve Pods per node. In this chapter, we might need more than thirty-six Pods across the cluster. Instead of creating a cluster with more than three nodes, we'll add Cluster Autoscaler (CA) to the mix, and let the cluster expand if needed. We already explored CA in one of the previous chapters and the setup instructions are now added to the Gist eks-hpa-custom.sh (https://gist.github.com/vfarcic/868bf70ac2946458f5485edea1f6fc4c).
Even though three t2.small nodes we used so far have more than enough memory and CPU, they might not be able to host all the Pods we'll create. EKS (by default) uses AWS networking. A t2.small instance can have a maximum of three network interfaces, with four IPv4 address per each. That means that we can have up to twelve IPv4 addresses on each t2.small node. Given that each Pod needs to have its own address, that means that we can have a maximum of twelve Pods per node. In this chapter, we might need more than thirty-six Pods across the cluster. Instead of creating a cluster with more than three nodes, we'll add Cluster Autoscaler (CA) to the mix, and let the cluster expand if needed. We already explored CA in one of the previous chapters and the setup instructions are now added to the Gist eks-hpa-custom.sh (https://gist.github.com/vfarcic/868bf70ac2946458f5485edea1f6fc4c).
Please use one of the Gists that follow to create a new cluster. If you already have a cluster you'd like to use for the exercises, please use the Gists to validate that it fulfills all the requirements.
- gke-instrument.sh: GKE with 3 n1-standard-1 worker nodes, nginx Ingress, tiller, Prometheus Chart, and environment variables LB_IP, PROM_ADDR, and AM_ADDR (https://gist.github.com/vfarcic/675f4b3ee2c55ee718cf132e71e04c6e).
- eks-hpa-custom.sh: EKS with 3 t2.small worker nodes, nginx Ingress, tiller, Metrics Server, Prometheus Chart, environment variables LB_IP, PROM_ADDR, and AM_ADDR, and Cluster Autoscaler (https://gist.github.com/vfarcic/868bf70ac2946458f5485edea1f6fc4c).
- aks-instrument.sh: AKS with 3 Standard_B2s worker nodes, nginx Ingress, and tiller, Prometheus Chart, and environment variables LB_IP, PROM_ADDR, and AM_ADDR (https://gist.github.com/vfarcic/65a0d5834c9e20ebf1b99225fba0d339).
- docker-instrument.sh: Docker for Desktop with 2 CPUs, 3 GB RAM, nginx Ingress, tiller, Metrics Server, Prometheus Chart, and environment variables LB_IP, PROM_ADDR, and AM_ADDR (https://gist.github.com/vfarcic/1dddcae847e97219ab75f936d93451c2).
- minikube-instrument.sh: Minikube with 2 CPUs, 3 GB RAM, ingress, storage-provisioner, default-storageclass, and metrics-server addons enabled, tiller, Prometheus Chart, and environment variables LB_IP, PROM_ADDR, and AM_ADDR (https://gist.github.com/vfarcic/779fae2ae374cf91a5929070e47bddc8).
Now we're ready to extend our usage of HPA. But, before we do that, let's briefly explore (again) how HPA works out of the box.