mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-05 19:21:37 +00:00
added healthz check to the proxy with configurable port
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user