Move around some packages (#658)
* Move tracing exporter registration This doesn't belong in the library and should be configured by the consumer of the opencensus package. * Rename `vkublet` package to `node` `vkubelet` does not convey any information to the consumers of the package. Really it would be nice to move this package to the root of the repo, but then you wind up with... interesting... import semantics due to the repo name... and after thinking about it some, a subpackage is really not so bad as long as it has a name that convey's some information. `node` was chosen since this package deals with all the semantics of operating a node in Kubernetes.
This commit is contained in:
48
node/doc.go
Normal file
48
node/doc.go
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
Package node implements the components for operating a node in Kubernetes.
|
||||
This includes controllers for managin the node object, running scheduled pods,
|
||||
and exporting HTTP endpoints expected by the Kubernets API server.
|
||||
|
||||
There are two primary controllers, the node runner and the pod runner.
|
||||
|
||||
nodeRunner, _ := node.NewNodeController(...)
|
||||
// setup other things
|
||||
podRunner, _ := node.NewPodController(...)
|
||||
|
||||
go podRunner.Run(ctx)
|
||||
|
||||
select {
|
||||
case <-podRunner.Ready():
|
||||
go nodeRunner.Run(ctx)
|
||||
case <-ctx.Done()
|
||||
return ctx.Err()
|
||||
}
|
||||
|
||||
After calling start, cancelling the passed in context will shutdown the
|
||||
controller.
|
||||
Note this example elides error handling.
|
||||
|
||||
Up to this point you have an active node in Kubernetes which can have pods scheduled
|
||||
to it. However the API server expects nodes to implement API endpoints in order
|
||||
to support certain features such as fetching logs or execing a new process.
|
||||
The api package provides some helpers for this:
|
||||
`api.AttachPodRoutes` and `api.AttachMetricsRoutes`.
|
||||
|
||||
mux := http.NewServeMux()
|
||||
api.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 `node/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.
|
||||
*/
|
||||
package node
|
||||
Reference in New Issue
Block a user