From 750d7caf304d96555444d151c25d0db10efd4c6e Mon Sep 17 00:00:00 2001 From: Michelle Noorali Date: Mon, 1 Feb 2016 06:44:42 -0500 Subject: [PATCH] add health check to resourcifier --- install.yaml | 7 +++++++ resourcifier/main.go | 11 ++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/install.yaml b/install.yaml index 626624e74..3d8dc042a 100644 --- a/install.yaml +++ b/install.yaml @@ -103,6 +103,13 @@ spec: containers: - env: [] image: gcr.io/dm-k8s-testing/resourcifier:latest + imagePullPolicy: Always + livenessProbe: + httpGet: + path: /healthz + port: 8080 + initialDelaySeconds: 30 + timeoutSeconds: 1 name: resourcifier ports: - containerPort: 8080 diff --git a/resourcifier/main.go b/resourcifier/main.go index d00f5a70f..c43b92b04 100644 --- a/resourcifier/main.go +++ b/resourcifier/main.go @@ -17,6 +17,7 @@ limitations under the License. package main import ( + "github.com/kubernetes/deployment-manager/util" "github.com/kubernetes/deployment-manager/version" "flag" @@ -38,7 +39,9 @@ type Route struct { Type string } -var routes = []Route{} +var routes = []Route{ + {"HealthCheck", "/healthz", "GET", healthCheckHandlerFunc, ""}, +} // port to listen on var port = flag.Int("port", 8080, "The port to listen on") @@ -74,3 +77,9 @@ func main() { log.Printf("Listening on port %d...", *port) log.Fatal(http.ListenAndServe(address, handler)) } + +func healthCheckHandlerFunc(w http.ResponseWriter, r *http.Request) { + handler := "manager: get health" + util.LogHandlerEntry(handler, r) + util.LogHandlerExitWithText(handler, w, "OK", http.StatusOK) +}