Hi,
If livenessprobe is configured as below, the Pod will be verified (every specified interval) against sublink /healthz and port 8080. If the response is 200, the Pod is considered to be working fine and any other response greater then or equal to 400 is considered to be failed and the Pod gets restarted by the k8s. However my question is - if I want to perform certain action(e.g. trigger a command inside Pod) if the liveness probe response is 500, is it possible to configure so while creating the Pod?
livenessProbe:
httpGet:
path: /healthz
port: 8080
The k8s document provides the below snippets however this seems to be done separately on the server (i.e. not from the yaml file).
http.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
duration := time.Now().Sub(started)
if duration.Seconds() > 10 {
w.WriteHeader(500)
w.Write([]byte(fmt.Sprintf("error: %v", duration.Seconds())))
} else {
w.WriteHeader(200)
w.Write([]byte("ok"))
}
})