mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-05 03:03:40 +00:00
Refactoring cAdvisor interface into a package.
This will make it easier to start running the real cAdvisor alongside Kubelet. This change is primarily no-op refactoring. The main behavioral change is that we always create a cAdvisor interface and expect it to always be available. When we make a request, if cAdvisor is not connected the request fails with a connection error. This failure is handled today as well.
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"net"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
@@ -30,6 +31,7 @@ import (
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/credentialprovider"
|
||||
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/healthz"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/cadvisor"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/config"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/volume"
|
||||
@@ -38,6 +40,7 @@ import (
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||
|
||||
"github.com/golang/glog"
|
||||
cadvisorClient "github.com/google/cadvisor/client"
|
||||
"github.com/spf13/pflag"
|
||||
)
|
||||
|
||||
@@ -398,6 +401,16 @@ func createAndInitKubelet(kc *KubeletConfig, pc *config.PodConfig) (*kubelet.Kub
|
||||
} else {
|
||||
kubeClient = kc.KubeClient
|
||||
}
|
||||
|
||||
cc, err := cadvisorClient.NewClient("http://127.0.0.1:" + strconv.Itoa(int(kc.CAdvisorPort)))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cadvisorInterface, err := cadvisor.New(cc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
k, err := kubelet.NewMainKubelet(
|
||||
kc.Hostname,
|
||||
kc.DockerClient,
|
||||
@@ -416,7 +429,8 @@ func createAndInitKubelet(kc *KubeletConfig, pc *config.PodConfig) (*kubelet.Kub
|
||||
kc.MasterServiceNamespace,
|
||||
kc.VolumePlugins,
|
||||
kc.StreamingConnectionIdleTimeout,
|
||||
kc.Recorder)
|
||||
kc.Recorder,
|
||||
cadvisorInterface)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -425,7 +439,6 @@ func createAndInitKubelet(kc *KubeletConfig, pc *config.PodConfig) (*kubelet.Kub
|
||||
k.BirthCry()
|
||||
|
||||
go k.GarbageCollectLoop()
|
||||
go kubelet.MonitorCAdvisor(k, kc.CAdvisorPort)
|
||||
|
||||
return k, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user