Web/SpringBoot

Configure Pod readiness with Spring Actuator

벨포트조던 2019. 11. 20.
반응형

Sometime back I worked on adapating a bank’s application runbook using Ansible. Ansible was great it did need any external agents. So we started creating playbooks and deploying applications. But then the automation challange was how do we determine an application is ready ? so that we proceed deployment of next microservice. In our stack some application were age old spring 2.x applications while some were new age SpringBoot 2.0 based applications. SpingBoot provides actuator endpoints which lead us to the eventual solution. We added extensions to the /health endpoint, checking the availabily of our application dependencis. In older appliations we added dropwizard and created a similar ecosystem. In the end we added health check to each our service Ansible startup. Well that was Ansible but now we are adapting Kubernetes.

On kubernetes platform most of our containers are running a java application. These are springBoot applications with embeded servlet engines executed with the command java -jar service.jar. In the container world as well we have the challage of application readiness. So we can hack our way adapting the Ansible approach, by adding a /health endpoint check to our startup script. But this is NOT the recomended K8s best practice. Instead of this K8s provide container probes to determine a container status. There are two kinds of probes :

  • liveliness probe : This is meant to determine is the container is running.
  • readiness probe : This is meant to determine is the container is ready to accept connections.

The probe defination can be added to the deployment.yaml and thus we can leverage the readiness check. Lets look at the following deployment.yaml

 

 

추가 코드는 출처에서~

 

https://rahulsharma.page/2019-01-02-k8s-springboot-readinessCheck/

반응형

댓글