Skip to content

Commit 55f50f5

Browse files
committed
feat(server): add readiness probe
1 parent ecb1da0 commit 55f50f5

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

kubernetes/deployment.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,11 @@ spec:
3737
port: 8080
3838
initialDelaySeconds: 10
3939
periodSeconds: 10
40+
41+
readinessProbe:
42+
httpGet:
43+
path: /readyz
44+
port: 8080
45+
initialDelay: 20
46+
periodSeconds: 10
4047

minikube-infra/deployment.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ resource "kubernetes_deployment" "origoss_task_server" {
5656
initial_delay_seconds = 10
5757
period_seconds = 10
5858
}
59+
60+
readiness_probe {
61+
http_get {
62+
path = "/readyz"
63+
port = 8080
64+
}
65+
initial_delay_seconds = 20
66+
period_seconds= 10
67+
}
5968
}
6069
}
6170
}

server/main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ func getHealth(w http.ResponseWriter, r *http.Request) {
2020
log.Println("Health check requested")
2121
}
2222

23+
func getReadiness(w http.ResponseWriter, r *http.Request) {
24+
w.WriteHeader(http.StatusOK)
25+
log.Println("Readiness check requested")
26+
}
27+
2328

2429
func loadPort() string {
2530
port := os.Getenv("PORT")
@@ -36,6 +41,7 @@ func main() {
3641
var port string = loadPort();
3742
http.HandleFunc("/", getRoot)
3843
http.HandleFunc("/healthz", getHealth)
44+
http.HandleFunc("/readyz", getReadiness)
3945
http.Handle("/metrics", promhttp.Handler())
4046
address := net.JoinHostPort("", port)
4147
log.Println("Server is running on port", port)

0 commit comments

Comments
 (0)