From 7a47ea891338b8c13763c12730fad81834a7da48 Mon Sep 17 00:00:00 2001 From: Dawn Chen Date: Thu, 5 Mar 2015 17:09:04 -0800 Subject: [PATCH] Ask monit health check kubelet; if failed, restart. --- cluster/saltbase/salt/monit/kubelet | 5 ++++- pkg/kubelet/server.go | 12 +++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/cluster/saltbase/salt/monit/kubelet b/cluster/saltbase/salt/monit/kubelet index ab8ee30b598..cbde975ac92 100644 --- a/cluster/saltbase/salt/monit/kubelet +++ b/cluster/saltbase/salt/monit/kubelet @@ -3,4 +3,7 @@ group kubelet start program = "/etc/init.d/kubelet start" stop program = "/etc/init.d/kubelet stop" if does not exist then restart - +if failed port 10250 + protocol HTTP request "/healthz" + with timeout 10 seconds + then restart diff --git a/pkg/kubelet/server.go b/pkg/kubelet/server.go index 7433d9d7ab6..61967b1bb55 100644 --- a/pkg/kubelet/server.go +++ b/pkg/kubelet/server.go @@ -165,13 +165,11 @@ func (s *Server) handleHealthz(w http.ResponseWriter, req *http.Request) { // Check that the hostname known by the master matches the hostname // the kubelet knows - /* - hostname := s.host.GetHostname() - if masterHostname != hostname { - s.error(w, errors.New("Kubelet hostname \""+hostname+"\" does not match the hostname expected by the master \""+masterHostname+"\"")) - return - } - */ + hostname := s.host.GetHostname() + if masterHostname != hostname && masterHostname != "127.0.0.1" && masterHostname != "localhost" { + s.error(w, errors.New("Kubelet hostname \""+hostname+"\" does not match the hostname expected by the master \""+masterHostname+"\"")) + return + } w.Write([]byte("ok")) }