This repository contains Kubernetes manifests to demonstrate the configuration of the Horizontal Pod Autoscaler (HPA). HPA automatically scales the number of pod replicas in a deployment based on observed CPU utilization or other select metrics.
deployment.yaml: Defines the Deployment resource for the application.service.yaml: Specifies the Service resource to expose the application.ingress.yaml: Configures Ingress resource for external access to the application.k8s_hpa.yaml: Contains the HPA configuration to enable automatic scaling.
- A running Kubernetes cluster.
kubectlconfigured to interact with your cluster.- Metrics Server installed in the cluster to provide resource utilization metrics.
-
Deploy the Application:
Apply the Deployment and Service manifests to deploy the application:
kubectl apply -f deployment.yaml kubectl apply -f service.yaml
-
Configure Ingress (Optional):
If you have an Ingress controller set up and wish to expose the application externally, apply the Ingress manifest:
kubectl apply -f ingress.yaml
-
Set Up Horizontal Pod Autoscaler:
Apply the HPA configuration to enable automatic scaling:
kubectl apply -f k8s_hpa.yaml
-
Verify HPA Status:
Check the status of the HPA to ensure it's monitoring the application's metrics:
kubectl get hpa
For detailed information:
kubectl describe hpa
- Deployment: Modify
deployment.yamlto change the application's image, resource requests, and limits. - HPA Configuration: Adjust
k8s_hpa.yamlto set different metrics, utilization thresholds, or replica counts as needed.