From ac947b10b878174c1e56f7eefa7567e294e8988a Mon Sep 17 00:00:00 2001 From: Brian Goff Date: Fri, 17 May 2019 17:01:05 -0700 Subject: [PATCH] Decouple vkubelet/* packages from providers (#626) This makes the concept of a `Provider` wholely implemented in the cli implementation in cmd/virtual-kubelet. It allows us to slim down the interfaces used in vkubelet (and vkubelet/api) to what is actually used there rather than a huge interface that is only there to serve the CLI's needs. --- virtual-kubelet/commands/root/http.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/virtual-kubelet/commands/root/http.go b/virtual-kubelet/commands/root/http.go index 14e00c3..3668fe0 100644 --- a/virtual-kubelet/commands/root/http.go +++ b/virtual-kubelet/commands/root/http.go @@ -26,7 +26,7 @@ import ( "github.com/pkg/errors" "github.com/virtual-kubelet/virtual-kubelet/log" "github.com/virtual-kubelet/virtual-kubelet/providers" - "github.com/virtual-kubelet/virtual-kubelet/vkubelet" + "github.com/virtual-kubelet/virtual-kubelet/vkubelet/api" ) // AcceptedCiphers is the list of accepted TLS ciphers, with known weak ciphers elided @@ -86,7 +86,13 @@ func setupHTTPServer(ctx context.Context, p providers.Provider, cfg *apiServerCo } mux := http.NewServeMux() - vkubelet.AttachPodRoutes(p, mux, true) + + podRoutes := api.PodHandlerConfig{ + RunInContainer: p.RunInContainer, + GetContainerLogs: p.GetContainerLogs, + GetPods: p.GetPods, + } + api.AttachPodRoutes(podRoutes, mux, true) s := &http.Server{ Handler: mux, @@ -105,7 +111,15 @@ func setupHTTPServer(ctx context.Context, p providers.Provider, cfg *apiServerCo } mux := http.NewServeMux() - vkubelet.AttachMetricsRoutes(p, mux) + + var summaryHandlerFunc api.PodStatsSummaryHandlerFunc + if mp, ok := p.(providers.PodMetricsProvider); ok { + summaryHandlerFunc = mp.GetStatsSummary + } + podMetricsRoutes := api.PodMetricsConfig{ + GetStatsSummary: summaryHandlerFunc, + } + api.AttachPodMetricsRoutes(podMetricsRoutes, mux) s := &http.Server{ Handler: mux, }