-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
📖 Add project overview to docs, clean up docs, structure #295
📖 Add project overview to docs, clean up docs, structure #295
Conversation
This lays out package docs for the client package, clarifies that client.New creates a new direct-to-API client, and adds an example for indexers.
This adds an overview of the library to the root package.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: DirectXMan12 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good, some minor nits.
doc.go
Outdated
// | ||
// Controllers | ||
// | ||
// Controllers (pkg/controller) handle using events (pkg/events) to eventually |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/handle using/handle
doc.go
Outdated
// Logging and Metrics | ||
// | ||
// Logging (pkg/log) in controller-runtime is done via structured logs, using a | ||
// log interface set called logr (https://godoc.org/github.com/go-logr/logr). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/interface set/interface ?
doc.go
Outdated
// | ||
// Metrics (pkg/metrics) provided by controller-runtime are registered into a | ||
// controller-runtime-specific Prometheus metrics registery. The manager will | ||
// serve these by default at an HTTP endpoint, and additional metrics may be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we serve the metrics by default. We wanted to, but couldn't so because scaffolded tests won't be able to run in parallel because of port-conflict.
// stand up a copy of etcd and kube-apiserver, and provide the correct options | ||
// to connect to the API server. It's designed to work well with the Ginkgo | ||
// testing framework, but should work with any testing setup. | ||
package controllerruntime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely written overview.
pkg/client/example_test.go
Outdated
@@ -196,3 +198,24 @@ func ExampleClient_delete() { | |||
}) | |||
_ = c.Delete(context.Background(), u) | |||
} | |||
|
|||
// This example shows how to set up and consume a field select over a pod's volumes' secretName field. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/field select/field selector
pkg/manager/manager.go
Outdated
@@ -84,7 +84,8 @@ type Manager interface { | |||
// Options are the arguments for creating a new Manager | |||
type Options struct { | |||
// Scheme is the scheme used to resolve runtime.Objects to GroupVersionKinds / Resources | |||
// Defaults to the kubernetes/client-go scheme.Scheme | |||
// Defaults to the kubernetes/client-go scheme.Scheme, but it's almost always a good | |||
// idea to pass your own scheme in. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have seen users struggling with this. I think we can provide some guidance here: For ex. user is writing controllers with built-in types, then default scheme is enough, but if using your own types/external-types, augment the default scheme with the scheme for specific types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added more documentation on schemes to pkg/runtime/scheme, which probably should be promoted to pkg/scheme
.
4fc3d07
to
436eac7
Compare
This cleans up the existing docs, clarifying working, improving spacing, and making sure all packages have docs.
Manager previously conformed to a slightly different interface than recorder.Provider. This fixes that.
pkg/runtime is a bit of a odd collection right now. This starts to move stuff out of it, leaving aliases in place instead. Since signals are used to control managers, this functionality now lives in a subpackage of manager.
Continue moving stuff out of pkg/runtime. the schemebuilder now lives in pkg/scheme.
436eac7
to
d5457b0
Compare
FAQ.md
Outdated
|
||
- When you can, take advantage of optimistic locking: use deterministic | ||
names for objects you create, so that the Kubernetes API server will | ||
warn you if the object already exists. May controllers in Kubernetes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/May/Many/
FAQ.md
Outdated
|
||
**A**: The fake client | ||
[exists](https://godoc.org/sigs.k8s.io/controller-runtime/pkg/client/fake), | ||
but we generally reccomend using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/reccomend/recommend/
FAQ.md
Outdated
[envtest.Environment](https://godoc.org/sigs.k8s.io/controller-runtime/pkg/envtest#Environment) | ||
to spin up a real API server instead of trying to mock one out. | ||
|
||
- Structure your tests to check the that the state of the world is as you |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/check the that/check that/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me (there are minor nits pointed out by another reviewer).
from the API groups that it needs (be they Kubernetes types or your own). | ||
See the [scheme builder | ||
docs](https://godoc.org/sigs.k8s.io/controller-runtime/pkg/scheme) for | ||
more information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is excellent. We should add these to kubebuilder book.
@@ -25,7 +25,7 @@ import ( | |||
"sigs.k8s.io/controller-runtime/pkg/manager" | |||
"sigs.k8s.io/controller-runtime/pkg/reconcile" | |||
"sigs.k8s.io/controller-runtime/pkg/log" | |||
"sigs.k8s.io/controller-runtime/pkg/runtime/scheme" | |||
"sigs.k8s.io/controller-runtime/pkg/scheme" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am guessing this might impact scaffolded code.
Note to self: Audit scaffolded code (and figure out if migration guide needs to be written for cr-0.2.0) and update it to use cr-0.2.0.
func (bld *Builder) Build() (*runtime.Scheme, error) { | ||
s := runtime.NewScheme() | ||
return s, bld.AddToScheme(s) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice.
general, your application should have its own Scheme containing the types | ||
from the API groups that it needs (be they Kubernetes types or your own). | ||
See the [scheme builder | ||
docs](https://godoc.org/sigs.k8s.io/controller-runtime/pkg/scheme) for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s|controller-runtime/pkg/scheme
|controller-runtime/pkg/runtime/scheme
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above changes
I have a habit of spelling it with 2 'c's and one 'm'.
d5457b0
to
cb0aefb
Compare
/lgtm |
IIRC we are not going to release again in |
The package moves left aliases in place, so they shouldn't actually be breaking yet. |
// GetRecorder returns a new EventRecorder for the provided name | ||
GetRecorder(name string) record.EventRecorder | ||
// GetEventRecorderFor returns a new EventRecorder for the provided name | ||
GetEventRecorderFor(name string) record.EventRecorder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change. Was that intentional? If not, can we add the GetRecorder
method back and deprecate it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was marked as breaking (on the commit). Did it make it into a stable branch? We should do a patch to the stable branch to restore it if so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't look like it made it into a stable branch (it's not on release-0.1). Master is intended to have breaking changes, and yes, this was intended to be breaking (it brings manager in line with other things that provide a recorder).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I missed the breaking mark (I wasn't aware of the meaning of
This adds an overview of the project organization to the root godocs, and cleans up the docs here and there, fixing whitespace issues, cleaning up wording, clarifying, and adding docs where they're lacking.
This also moves things out of pkg/runtime, so that pkg/runtime is (mostly) deprecated paths to other things.