Skip to content

Commit

Permalink
doc/user-guide: add docs for advanced controller configurations (#1783)
Browse files Browse the repository at this point in the history
  • Loading branch information
hasbro17 authored Aug 9, 2019
1 parent f509fcd commit c1e2eae
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions doc/user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,20 @@ err := c.Watch(&source.Kind{Type: &appsv1.Deployment{}}, &handler.EnqueueRequest
})
```

**// TODO:** Doc on eventhandler, arbitrary mapping between watched and reconciled resource.
#### Controller configurations

There are a number of useful configurations that can be made when initialzing a controller and declaring the watch parameters. For more details on these configurations consult the upstream [controller godocs][controller_godocs].

- Set the max number of concurrent Reconciles for the controller via the [`MaxConcurrentReconciles`][controller_options] option. Defaults to 1.
```Go
_, err := controller.New("memcached-controller", mgr, controller.Options{
MaxConcurrentReconciles: 2,
...
})
```
- Filter watch events using [predicates][event_filtering]
- Choose the type of [EventHandler][event_handler_godocs] to change how a watch event will translate to reconcile requests for the reconcile loop. For operator relationships that are more complex than primary and secondary resources, the [`EnqueueRequestsFromMapFunc`][enqueue_requests_from_map_func] handler can be used to transform a watch event into an arbitrary set of reconcile requests.

**// TODO:** Doc on configuring a Controller: number of workers, predicates, watching channels,

### Reconcile loop

Expand Down Expand Up @@ -614,6 +625,11 @@ func main() {

When the operator is not running in a cluster, the Manager will return an error on starting since it can't detect the operator's namespace in order to create the configmap for leader election. You can override this namespace by setting the Manager's `LeaderElectionNamespace` option.

[enqueue_requests_from_map_func]: https://godoc.org/sigs.k8s.io/controller-runtime/pkg/handler#EnqueueRequestsFromMapFunc
[event_handler_godocs]: https://godoc.org/sigs.k8s.io/controller-runtime/pkg/handler#hdr-EventHandlers
[event_filtering]:./user/event-filtering.md
[controller_options]: https://godoc.org/github.com/kubernetes-sigs/controller-runtime/pkg/controller#Options
[controller_godocs]: https://godoc.org/github.com/kubernetes-sigs/controller-runtime/pkg/controller
[operator_scope]:./operator-scope.md
[install_guide]: ./user/install-operator-sdk.md
[pod_eviction_timeout]: https://kubernetes.io/docs/reference/command-line-tools-reference/kube-controller-manager/#options
Expand Down

0 comments on commit c1e2eae

Please sign in to comment.