{"id":22173818,"url":"https://github.com/puneethkumarck/spring-microservice-autoscale","last_synced_at":"2026-07-17T00:31:35.079Z","repository":{"id":129141316,"uuid":"462041162","full_name":"Puneethkumarck/spring-microservice-autoscale","owner":"Puneethkumarck","description":null,"archived":false,"fork":false,"pushed_at":"2022-02-22T10:40:12.000Z","size":1492,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-29T22:46:11.472Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Puneethkumarck.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-21T21:42:20.000Z","updated_at":"2024-11-08T02:37:06.000Z","dependencies_parsed_at":"2023-04-17T09:48:28.334Z","dependency_job_id":null,"html_url":"https://github.com/Puneethkumarck/spring-microservice-autoscale","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Puneethkumarck%2Fspring-microservice-autoscale","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Puneethkumarck%2Fspring-microservice-autoscale/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Puneethkumarck%2Fspring-microservice-autoscale/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Puneethkumarck%2Fspring-microservice-autoscale/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Puneethkumarck","download_url":"https://codeload.github.com/Puneethkumarck/spring-microservice-autoscale/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245325223,"owners_count":20596818,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-02T07:35:40.414Z","updated_at":"2025-10-24T09:38:32.107Z","avatar_url":"https://github.com/Puneethkumarck.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HPA (Horizontel Pod AutoScaler) Demo with SpringBoot with K8s\n\n### Pre requisite installation\n\n* Java 11\n* maven\n* kubernetes docker for desktop/minikube\n\n### Tech\n* Java 11\n* Springboot\n* Spring-Data-Jpa\n* Spring-Boot-Actuator\n* Lombok\n* Maven\n* kubernetes\n* Docker\n\n\n### Build\n\n mvn clean install\n\n```\nBuild docker image \n\ndocker build -t spring-microservice-autoscale-deployment:v3 . \n```\n\n### Run\n\n1. Metricserver in docker for desktop is not enabled by default, apply follwoing command  \n\n```\nkubectl create -f metricsserver/\n```\n\n2. Deploy the k8s resources by following command \n\n```\nkubectl create -f k8s/\n```\n\n![img.png](images/initial_deployment.png)\n\n3. check the k8s pod,service, deployment and hpa deployed in previous step \n\n```\nkubectl get po,svc,deployment,hpa \n```\n![img.png](images/display_resources.png)\n\n4. Check the pod status\n```\nkubectl get po\n```\n![img.png](images/pod_creation.png)\n\n5. check the HPA status and observe the Targets column for resource consumption \n\n```\n kubectl get hpa\n ```\n![img.png](images/hpa.png)\n\n6. Wait for pod scale down to 1 (i.e, Min Replica Config)\n\n\n7. Perform the Load Test . Run the below command in the separate command line window\n\n```\nwhile true; do curl http://localhost:8080/retrieve; done\n```\n\n8. Run below command in separate window to watch HPA status every 30 sec, observe Target column to see variations in the CPU consumptions\n\n```\n   kubectl get hpa -w\n```\n\n   ![img.png](images/hpa2.png)\n   \n9. Check the Kuberentes events to understand scaling up and down events in background \n\n```\nkubectl get events\n```\n\n   ![img.png](images/kube_events.png)\n\n10. terminate the load testing\n\n11. Wait for sometime and verify change in HPA and Kubernetes events to scaling down the pod to minimum replica count , since CPU consumption is low\n\n12. clean up resources \u003cb\u003ekubectl delete -f k8s/\n\n## K8s Commands used\n\n* kubectl create -f k8s/\n* kubectl get po,svc,deployment,hpa\n* kubectl get po\n* kubectl get hpa -w\n* kubectl get events\n* kubectl describe deploy spring-microservice-autoscale-deployment\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpuneethkumarck%2Fspring-microservice-autoscale","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpuneethkumarck%2Fspring-microservice-autoscale","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpuneethkumarck%2Fspring-microservice-autoscale/lists"}