mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
added healthz check to the proxy with configurable port
This commit is contained in:
parent
162e4983b9
commit
5bda95f9fe
@ -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
|
||||
|
@ -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
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user