For Spring Boot 1.X, you won't have these endpoints out of the box. However, you can implement custom health check endpoints to achieve similar functionality.
Create Custom Health Indicators: Implement custom health indicators by extending the HealthIndicator interface provided by Spring Boot. You can write logic to determine the health status of different components of your application.
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.stereotype.Component;
@Component
public class CustomHealthIndicator implements HealthIndicator {
@Override
public Health health() {
// Logic to check the health of your application
if (isApplicationHealthy()) {
return Health.up().build();
} else {
return Health.down().build();
}
}
private boolean isApplicationHealthy() {
// Check the health of your application components
return true; // Return true if the application is healthy, false otherwise
}
}
Expose Custom Endpoints: Expose custom endpoints in your application controller to expose the health status information.
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.health.Health;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HealthCheckController {
@Autowired
private CustomHealthIndicator customHealthIndicator;
@GetMapping("/custom/health/liveness")
public Health liveness() {
return customHealthIndicator.health();
}
@GetMapping("/custom/health/readiness")
public Health readiness() {
return customHealthIndicator.health();
}
}
Configure Probes in Kubernetes: Once you have implemented these endpoints, you can configure Kubernetes to use them for readiness and liveness probes in your deployment configuration.
apiVersion: apps/v1
kind: Deployment
metadata:
name: your-app
spec:
replicas: 1
selector:
matchLabels:
app: your-app
template:
metadata:
labels:
app: your-app
spec:
containers:
- name: your-app
image: your-app-image:tag
ports:
- containerPort: 8080
readinessProbe:
httpGet:
path: /custom/health/readiness
port: 8080
livenessProbe:
httpGet:
path: /custom/health/liveness
port: 8080