- 如何优雅地停止 Spring Boot 应用? - 知乎 (zhihu.com)
- qoosdd89382/SpringBoot-Learn forked from wupeixuan/SpringBoot-Learn
sh script.sh {image_repo} {image_name}
For example:
sh script.sh qoosdd89382 graceful
Edit /deploy/deployment.yaml
by changing image:
field to your image repository, then run:
kubectl apply -f deploy/deployment.yaml
kubectl apply -f deploy/hpa.yaml
kubectl apply -f deploy/service.yaml
kubectl port-forward svc/graceful 8089:8089
Access localhost:8089/hpa
on your host, you will get a message like success
.
kubectl run curl --image=alpine/curl --rm -it -- sh
Then run command below in the pod:
while true; do curl graceful:8089/hpa; done
Highly recommend to install watch
tool. In Mac OSX:
brew install watch
After installing, run:
watch kubectl top pod
You need to check the version of HPA from your Kubernetes cluster:
$ kubectl api-versions | grep autoscaling ─╯
autoscaling/v1
autoscaling/v2
autoscaling/v2beta2
HorizontalPodAutoscaler in version "v1" cannot be handled as a HorizontalPodAutoscaler:
strict decoding error: unknown field "spec.behavior", unknown field "spec.metrics".