Skip to content

Multisource/Hierarchical Controller #1530

Closed
@jamescarterbell

Description

Would you like to work on this feature?

maybe

What problem are you trying to solve?

The current controller design is extremely powerful for designing single source watchers, i.e., one controller per record. However, this design as is makes it hard to design a fan-in style system, where one controller might need to operate across multiple records of a given type.

Describe the solution you'd like

For example, imagine the following system:

  1. Individual nodes in a cluster are deployed from a backing service that takes rate limited bulk calls.
  2. Each node posts it's own health record that can be acted upon to fix node issues.
  3. The backing node collection from the service also has a record that shows an accumulated count of healthy nodes.

Ideally, it would be possible to have a set up like so:

let hierarchy_controller = Controller::new(parent_api, Config::default())
   .with_child(child_api, map_child_to_parent)
   .run(reconcile, error_policy, ());

// ...

fn reconcile(parent: ParentType, children: HashMap<String, ChildType>) -> Result<Action> {
  // ...
}

Where reconcile would be called when the parent or children get updated.

In the motivating example, this would enable us to have a reconcile function that gets called whenever any node goes unhealthy, and issue one bulk call against all the currently unhealthy nodes in the reconcile loop, and update the parent record with the number of healthy nodes.

Describe alternatives you've considered

Currently, this would require one controller per node, and one controller for the node collection, with some sort of channel system between the controllers to communicate changes, and some hacky ways to make sure the reconcile loops get run at appropriate times.

This may also not be a good pattern in Kubernetes, but I'm not really sure what major flaws it would have.

Documentation, Adoption, Migration Strategy

No response

Target crate for feature

kube-runtime

Metadata

Assignees

No one assigned

    Labels

    questionDirection unclear; possibly a bug, possibly could be improved.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions