Skip to content

Link to documentation from README.md #69

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

Merged
merged 1 commit into from
Jul 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@

The Kubernetes controller-runtime Project is a set of go libraries for building Controllers.

Documentation:

- Package overview [link](https://godoc.org/github.com/kubernetes-sigs/controller-runtime/pkg)
- Basic controller using builder [link](https://godoc.org/github.com/kubernetes-sigs/controller-runtime/pkg/builder#example-Builder)
- Creating a manager [link](https://godoc.org/github.com/kubernetes-sigs/controller-runtime/pkg/manager#example-New)
- Creating a controller[link](https://godoc.org/github.com/kubernetes-sigs/controller-runtime/pkg/controller#example-New)

Example: [main](https://github.com/kubernetes-sigs/controller-runtime/blob/master/example/main.go)

## Community, discussion, contribution, and support

Expand Down
25 changes: 9 additions & 16 deletions pkg/controller/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,12 @@ func ExampleNew() {
}
}

// This example creates a new Controller named "pod-controller" with a no-op reconcile function and registers
// it with the DefaultControllerManager.
// This example starts a new Controller named "pod-controller" to Watch Pods and call a no-op Reconciler.
func ExampleController() {
_, err := controller.New("pod-controller", mrg, controller.Options{
Reconciler: reconcile.Func(func(o reconcile.Request) (reconcile.Result, error) {
// Your business logic to implement the API by creating, updating, deleting objects goes here.
return reconcile.Result{}, nil
}),
})
if err != nil {
log.Fatal(err)
}
mrg.Start(signals.SetupSignalHandler())
}
// mrg is a manager.Manager

// This example watches Pods and enqueues reconcile.Requests with the changed Pod Name and Namespace.
func ExampleController_Watch() {
// Create a new Controller that will call the provided Reconciler function in response
// to events.
c, err := controller.New("pod-controller", mrg, controller.Options{
Reconciler: reconcile.Func(func(o reconcile.Request) (reconcile.Result, error) {
// Your business logic to implement the API by creating, updating, deleting objects goes here.
Expand All @@ -71,11 +60,15 @@ func ExampleController_Watch() {
log.Fatal(err)
}

// Watch for Pod create / update / delete events and call Reconcile
err = c.Watch(&source.Kind{Type: &v1.Pod{}}, &handler.EnqueueRequestForObject{})
if err != nil {
log.Fatal(err)
}
if err != nil {
log.Fatal(err)
}

// Start the Controller through the manager.
mrg.Start(signals.SetupSignalHandler())

}
7 changes: 6 additions & 1 deletion pkg/manager/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ var mrg manager.Manager

// This example creates a new Manager that can be used with controller.New to create Controllers.
func ExampleNew() {
mrg, err := manager.New(config.GetConfigOrDie(), manager.Options{})
cfg, err := config.GetConfig()
if err != nil {
log.Fatal(err)
}

mrg, err := manager.New(cfg, manager.Options{})
if err != nil {
log.Fatal(err)
}
Expand Down