mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-06 07:57:35 +00:00
Kubelet Metrics Summary Api Implementation
This commit is contained in:
@@ -27,8 +27,10 @@ import (
|
||||
"github.com/emicklei/go-restful"
|
||||
"github.com/golang/glog"
|
||||
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||
cadvisorapiv2 "github.com/google/cadvisor/info/v2"
|
||||
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/kubelet/cm"
|
||||
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
||||
"k8s.io/kubernetes/pkg/types"
|
||||
)
|
||||
@@ -36,16 +38,22 @@ import (
|
||||
// Host methods required by stats handlers.
|
||||
type StatsProvider interface {
|
||||
GetContainerInfo(podFullName string, uid types.UID, containerName string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error)
|
||||
GetContainerInfoV2(name string, options cadvisorapiv2.RequestOptions) (map[string]cadvisorapiv2.ContainerInfo, error)
|
||||
GetRawContainerInfo(containerName string, req *cadvisorapi.ContainerInfoRequest, subcontainers bool) (map[string]*cadvisorapi.ContainerInfo, error)
|
||||
GetPodByName(namespace, name string) (*api.Pod, bool)
|
||||
GetNode() (*api.Node, error)
|
||||
GetNodeConfig() cm.NodeConfig
|
||||
DockerImagesFsInfo() (cadvisorapiv2.FsInfo, error)
|
||||
RootFsInfo() (cadvisorapiv2.FsInfo, error)
|
||||
}
|
||||
|
||||
type handler struct {
|
||||
provider StatsProvider
|
||||
provider StatsProvider
|
||||
summaryProvider SummaryProvider
|
||||
}
|
||||
|
||||
func CreateHandlers(provider StatsProvider) *restful.WebService {
|
||||
h := &handler{provider}
|
||||
h := &handler{provider, NewSummaryProvider(provider)}
|
||||
|
||||
ws := &restful.WebService{}
|
||||
ws.Path("/stats/").
|
||||
@@ -137,11 +145,12 @@ func (h *handler) handleStats(request *restful.Request, response *restful.Respon
|
||||
|
||||
// Handles stats summary requests to /stats/summary
|
||||
func (h *handler) handleSummary(request *restful.Request, response *restful.Response) {
|
||||
summary := Summary{}
|
||||
|
||||
// TODO(timstclair): Fill in summary from cAdvisor v2 endpoint.
|
||||
|
||||
writeResponse(response, summary)
|
||||
summary, err := h.summaryProvider.Get()
|
||||
if err != nil {
|
||||
handleError(response, err)
|
||||
} else {
|
||||
writeResponse(response, summary)
|
||||
}
|
||||
}
|
||||
|
||||
// Handles non-kubernetes container stats requests to /stats/container/
|
||||
|
||||
Reference in New Issue
Block a user