From b678e2ff9e13dd07504d8bdf2add2b3f8da74e46 Mon Sep 17 00:00:00 2001 From: Prashanth Balasubramanian Date: Wed, 3 Jun 2015 22:13:59 -0700 Subject: [PATCH 1/3] Nodes returns transport and scheme in spite of port requirements --- pkg/registry/minion/rest.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/registry/minion/rest.go b/pkg/registry/minion/rest.go index 782770ef7c9..7080f5c56bd 100644 --- a/pkg/registry/minion/rest.go +++ b/pkg/registry/minion/rest.go @@ -129,7 +129,7 @@ func MatchNode(label labels.Selector, field fields.Selector) generic.Matcher { } } -// ResourceLocation returns a URL to which one can send traffic for the specified node. +// ResourceLocation returns an URL and transport which one can use to send traffic for the specified node. func ResourceLocation(getter ResourceGetter, connection client.ConnectionInfoGetter, ctx api.Context, id string) (*url.URL, http.RoundTripper, error) { name, portReq, valid := util.SplitPort(id) if !valid { @@ -143,15 +143,15 @@ func ResourceLocation(getter ResourceGetter, connection client.ConnectionInfoGet node := nodeObj.(*api.Node) host := node.Name // TODO: use node's IP, don't expect the name to resolve. - if portReq != "" { - return &url.URL{Host: net.JoinHostPort(host, portReq)}, nil, nil - } - scheme, port, transport, err := connection.GetConnectionInfo(host) if err != nil { return nil, nil, err } + if portReq != "" { + return &url.URL{Scheme: scheme, Host: net.JoinHostPort(host, portReq)}, transport, nil + } + return &url.URL{ Scheme: scheme, Host: net.JoinHostPort( From 99f8ddf304ced6c6245eb9fa742fb888a70759d1 Mon Sep 17 00:00:00 2001 From: Prashanth Balasubramanian Date: Wed, 3 Jun 2015 23:51:14 -0700 Subject: [PATCH 2/3] Enable profiling endpoints for kubelet --- pkg/kubelet/server.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/kubelet/server.go b/pkg/kubelet/server.go index d0881ea9ff5..35d709645bb 100644 --- a/pkg/kubelet/server.go +++ b/pkg/kubelet/server.go @@ -24,6 +24,7 @@ import ( "io" "net" "net/http" + "net/http/pprof" "net/url" "path" "strconv" @@ -146,6 +147,10 @@ func (s *Server) InstallDebuggingHandlers() { s.mux.HandleFunc("/logs/", s.handleLogs) s.mux.HandleFunc("/containerLogs/", s.handleContainerLogs) s.mux.Handle("/metrics", prometheus.Handler()) + + s.mux.HandleFunc("/debug/pprof/", pprof.Index) + s.mux.HandleFunc("/debug/pprof/profile", pprof.Profile) + s.mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol) } // error serializes an error object into an HTTP response. From 50eb9ad598daf4ab33de6e6608acf60570979441 Mon Sep 17 00:00:00 2001 From: Prashanth Balasubramanian Date: Fri, 5 Jun 2015 07:33:34 -0700 Subject: [PATCH 3/3] Use https only for the kubelet port --- cmd/kube-apiserver/app/server.go | 3 ++- pkg/registry/minion/rest.go | 33 ++++++++++++++++---------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cmd/kube-apiserver/app/server.go b/cmd/kube-apiserver/app/server.go index 4a6e7322830..30dc1305920 100644 --- a/cmd/kube-apiserver/app/server.go +++ b/cmd/kube-apiserver/app/server.go @@ -37,6 +37,7 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider" "github.com/GoogleCloudPlatform/kubernetes/pkg/master" + "github.com/GoogleCloudPlatform/kubernetes/pkg/master/ports" "github.com/GoogleCloudPlatform/kubernetes/pkg/tools" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" forked "github.com/GoogleCloudPlatform/kubernetes/third_party/forked/coreos/go-etcd/etcd" @@ -121,7 +122,7 @@ func NewAPIServer() *APIServer { RuntimeConfig: make(util.ConfigurationMap), KubeletConfig: client.KubeletConfig{ - Port: 10250, + Port: ports.KubeletPort, EnableHttps: true, HTTPTimeout: time.Duration(5) * time.Second, }, diff --git a/pkg/registry/minion/rest.go b/pkg/registry/minion/rest.go index 7080f5c56bd..70daaf1e990 100644 --- a/pkg/registry/minion/rest.go +++ b/pkg/registry/minion/rest.go @@ -29,6 +29,7 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/fields" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" + "github.com/GoogleCloudPlatform/kubernetes/pkg/master/ports" "github.com/GoogleCloudPlatform/kubernetes/pkg/registry/generic" "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" @@ -143,22 +144,20 @@ func ResourceLocation(getter ResourceGetter, connection client.ConnectionInfoGet node := nodeObj.(*api.Node) host := node.Name // TODO: use node's IP, don't expect the name to resolve. - scheme, port, transport, err := connection.GetConnectionInfo(host) - if err != nil { - return nil, nil, err + if portReq == "" || strconv.Itoa(ports.KubeletPort) == portReq { + scheme, port, transport, err := connection.GetConnectionInfo(host) + if err != nil { + return nil, nil, err + } + return &url.URL{ + Scheme: scheme, + Host: net.JoinHostPort( + host, + strconv.FormatUint(uint64(port), 10), + ), + }, + transport, + nil } - - if portReq != "" { - return &url.URL{Scheme: scheme, Host: net.JoinHostPort(host, portReq)}, transport, nil - } - - return &url.URL{ - Scheme: scheme, - Host: net.JoinHostPort( - host, - strconv.FormatUint(uint64(port), 10), - ), - }, - transport, - nil + return &url.URL{Host: net.JoinHostPort(host, portReq)}, nil, nil }