From 5bda95f9fec332cad16056d4688778a4cce7b66c Mon Sep 17 00:00:00 2001 From: Mike Danese Date: Fri, 21 Nov 2014 09:06:36 -0800 Subject: [PATCH] added healthz check to the proxy with configurable port --- cmd/kube-proxy/proxy.go | 13 +++++++++++++ pkg/master/ports/ports.go | 3 +++ 2 files changed, 16 insertions(+) diff --git a/cmd/kube-proxy/proxy.go b/cmd/kube-proxy/proxy.go index 2d0e6c9734a..61fb4f8b9dd 100644 --- a/cmd/kube-proxy/proxy.go +++ b/cmd/kube-proxy/proxy.go @@ -19,10 +19,13 @@ package main import ( "flag" "net" + "net/http" + "strconv" "time" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/client" + _ "github.com/GoogleCloudPlatform/kubernetes/pkg/healthz" "github.com/GoogleCloudPlatform/kubernetes/pkg/proxy" "github.com/GoogleCloudPlatform/kubernetes/pkg/proxy/config" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" @@ -38,6 +41,7 @@ var ( etcdConfigFile = flag.String("etcd_config", "", "The config file for the etcd client. Mutually exclusive with -etcd_servers") bindAddress = util.IP(net.ParseIP("0.0.0.0")) clientConfig = &client.Config{} + healthz_port = flag.Int("healthz_port", 10249, "The port to bind the health check server. Use 0 to disable.") ) func init() { @@ -100,6 +104,15 @@ func main() { } } + if *healthz_port > 0 { + go util.Forever(func() { + err := http.ListenAndServe(bindAddress.String()+":"+strconv.Itoa(*healthz_port), nil) + if err != nil { + glog.Errorf("Starting health server failed: %v", err) + } + }, 5*time.Second) + } + protocol := iptables.ProtocolIpv4 if net.IP(bindAddress).To4() == nil { protocol = iptables.ProtocolIpv6 diff --git a/pkg/master/ports/ports.go b/pkg/master/ports/ports.go index 8995bef1a81..4be19606003 100644 --- a/pkg/master/ports/ports.go +++ b/pkg/master/ports/ports.go @@ -26,4 +26,7 @@ const ( // ControllerManagerPort is the default port for the controller manager status server. // May be overridden by a flag at startup. ControllerManagerPort = 10252 + // ProxyPort is the default port for the proxy status server. + // May be overriden by a flag at startup. + ProxyPort = 10249 )