Readiness check
curl --request GET \
--url http://localhost:9002/healthz/readyimport requests
url = "http://localhost:9002/healthz/ready"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('http://localhost:9002/healthz/ready', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "9002",
CURLOPT_URL => "http://localhost:9002/healthz/ready",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://localhost:9002/healthz/ready"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("http://localhost:9002/healthz/ready")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:9002/healthz/ready")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"status": "ready",
"service": "authn-svc",
"version": "1.0.0",
"timestamp": "2024-01-15T10:30:00Z",
"checks": {
"database": {
"status": "healthy",
"latency": "2.5ms"
},
"accounts_service": {
"status": "healthy",
"latency": "1.2ms"
},
"notification_service": {
"status": "healthy",
"latency": "0.8ms"
}
}
}{
"status": "not_ready",
"service": "authn-svc",
"version": "1.0.0",
"timestamp": "2024-01-15T10:30:00Z",
"checks": {
"database": {
"status": "unhealthy",
"latency": "5000ms",
"error": "database connection failed"
}
}
}Health
Kubernetes Readiness
Kubernetes readiness probe endpoint.
Port: 9002 (private)
Performs comprehensive health checks:
- Database connectivity and query execution
- External service availability (accounts service, notification service)
Returns 200 OK when service can handle traffic, 503 Service Unavailable otherwise.
GET
/
healthz
/
ready
Readiness check
curl --request GET \
--url http://localhost:9002/healthz/readyimport requests
url = "http://localhost:9002/healthz/ready"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('http://localhost:9002/healthz/ready', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "9002",
CURLOPT_URL => "http://localhost:9002/healthz/ready",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://localhost:9002/healthz/ready"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("http://localhost:9002/healthz/ready")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:9002/healthz/ready")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"status": "ready",
"service": "authn-svc",
"version": "1.0.0",
"timestamp": "2024-01-15T10:30:00Z",
"checks": {
"database": {
"status": "healthy",
"latency": "2.5ms"
},
"accounts_service": {
"status": "healthy",
"latency": "1.2ms"
},
"notification_service": {
"status": "healthy",
"latency": "0.8ms"
}
}
}{
"status": "not_ready",
"service": "authn-svc",
"version": "1.0.0",
"timestamp": "2024-01-15T10:30:00Z",
"checks": {
"database": {
"status": "unhealthy",
"latency": "5000ms",
"error": "database connection failed"
}
}
}Response
Service is ready to handle traffic
Response from the readiness probe endpoint
⌘I
