From 5796be449b606826fd9fa56c72f91ebece596b2b Mon Sep 17 00:00:00 2001 From: Brian Goff Date: Mon, 7 Jan 2019 11:03:35 -0800 Subject: [PATCH] Adds some package docs (#479) Was just browing godoc and noticed we are missing some docs that would be quite useful. --- manager/doc.go | 7 +++++++ vkubelet/api/doc.go | 3 +++ vkubelet/doc.go | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 manager/doc.go create mode 100644 vkubelet/api/doc.go create mode 100644 vkubelet/doc.go diff --git a/manager/doc.go b/manager/doc.go new file mode 100644 index 000000000..612ed115b --- /dev/null +++ b/manager/doc.go @@ -0,0 +1,7 @@ +// Package manager provides access to kubernetes resources for providers. +// +// DEPRECATION WARNING: +// Though this package is still in use, it should be considered deprecated as it +// is just wrapping a k8s client and not much else. +// Implementers should look at replacing their use of this with something else. +package manager diff --git a/vkubelet/api/doc.go b/vkubelet/api/doc.go new file mode 100644 index 000000000..12c6d9a5d --- /dev/null +++ b/vkubelet/api/doc.go @@ -0,0 +1,3 @@ +// Package api implements HTTP handlers for handling requests that the kubelet +// would normally implement, such as pod logs, exec, etc. +package api diff --git a/vkubelet/doc.go b/vkubelet/doc.go new file mode 100644 index 000000000..061cf69fd --- /dev/null +++ b/vkubelet/doc.go @@ -0,0 +1,44 @@ +/* +Package vkubelet implements the core virtual-kubelet framework. +It contains everything reuired to implement a virtuak-kubelet, including the +core controller which reconciles pod states and API endpoints for things like +pod logs, exec, attach, etc. + +To get started, call the `New` with the appropriate config. When you are ready +to start the controller, which registers the node and starts watching for pod +changes, call `Run`. Taints can be used ensure the sceduler only schedules +certain workloads to your virtual-kubelet. + + vk := vkubelet.New(...) + // setup other things + ... + vk.Run(ctx, ...) + +After calling start, cancelling the passed in context will shutdown the +controller. + +Up to this point you have a running virtual kubelet controller, but no HTTP +handlers to deal with requests forwarded from the API server for things like +pod logs (e.g. user calls `kubectl logs myVKPod`). This package provides some +helpers for this: `AttachPodRoutes` and `AttachMetricsRoutes`. + + mux := http.NewServeMux() + vkubelet.AttachPodRoutes(provider, mux) + +You must configure your own HTTP server, but these helpers will add handlers at +the correct URI paths to your serve mux. You are not required to use go's +built-in `*http.ServeMux`, but it does implement the `ServeMux` interface +defined in this package which is used for these helpers. + +Note: The metrics routes may need to be attached to a different HTTP server, +depending on your configuration. + +For more fine-grained control over the API, see the `vkubelet/api` package which +only implements the HTTP handlers that you can use in whatever way you want. + +This uses open-cenesus to implement tracing (but no internal metrics yet) which +is propagated through the context. This is passed on even to the providers. We +may look at supporting custom propagaters for providers who would like to use a +different tracing format. +*/ +package vkubelet