Skip to content
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

controller: reconciliation workflows #9

Merged
merged 9 commits into from
Jul 29, 2024
Merged

Conversation

guicassolato
Copy link
Contributor

@guicassolato guicassolato commented Jul 24, 2024

Introduces new reconciler abstractions Workflow and Subscriber:

  • Workflow: runs an optional precondition reconciliation function, then dispatches the reconciliation event to a list of concurrent reconciliation tasks, and runs an optional postcondition reconciliation function.
  • Subscriber: calls the reconciler function of the first subscription that matches the event (resource, event type, object name)

Additionally:

  • controller topology simplified: no longer stored with the controller – since it's currently being rebuilt at every event (this can change in the future)
  • propagation of a new ResourceEvent struct through reconciliation calls: stores info about the API resource, event type (create/update/delete), old and new objects
  • kuadrant controller example updated to leverage the changes above:
    • new reconciliation workflow:
      • ❶ log event
      • ❷ save topology to file
      • ❸ effective policies
      • ❹ (gateway deleted) delete SecurityPolicy / (other events) reconcile SecurityPolicies
      • ❹ (gateway deleted) delete AuthorizationPolicy / (other events) reconcile AuthorizationPolicies
    • reconcilers moved to an internal package examples/kuadrant/reconcilers
    • docs: envoy gateway and multiple gateway providers docs moved to examples/kuadrant/docs
  • fix bug in the build of Istio AuthorizationPolicy rules: missing HTTPRoute hostnames

Introduces new reconciler abstractions `Dispatcher` and `Subscriber`:
* `Dispatcher`: runs an optional precondition reconciliation function and then dispatches the reconciliation event to a list of subsequent reconcilers.
* `Subscriber`: calls the reconciler function of the first subscription that matches the event

Additionally:
- controller topology was also simplified: no longer stored with the controller, since it's currently being rebuilt at every event (this can change in the future)
- propagation of a new ResourceEvent struct through reconciliation calls: stores info about the API resource, event type (create/update/delete), old and new objects
- kuadrant controller example updated to leverage the changes above:
  - new reconciliation workflow:
    1. log event
    2. save topology to file
    3. effective policies
    4. (gateway deleted) delete SecurityPolicy / (other events) reconcile SecurityPolicies
    4. (gateway deleted) delete AuthorizationPolicy / (other events) reconcile AuthorizationPolicies
  - reconcilers moved to an internal package examples/kuadrant/reconcilers
  - docs: envoy gateway and multiple gateway providers docs moved to examples/kuadrant/docs
- fix bug in the build of Istio AuthorizationPolicy rules: missing HTTPRoute hostnames

Signed-off-by: Guilherme Cassolato <[email protected]>
Signed-off-by: Guilherme Cassolato <[email protected]>
examples/kuadrant/main.go Outdated Show resolved Hide resolved
gwapiv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"

"github.com/kuadrant/policy-machinery/machinery"

kuadrantapis "github.com/kuadrant/policy-machinery/examples/kuadrant/apis"
)

var (
RateLimitPolicyKind = schema.GroupKind{Group: SchemeGroupVersion.Group, Kind: "RateLimit"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RateLimitPolicyKind = schema.GroupKind{Group: SchemeGroupVersion.Group, Kind: "RateLimit"}
RateLimitPolicyKind = schema.GroupKind{Group: SchemeGroupVersion.Group, Kind: "RateLimitPolicy"}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Time to start writing tests 😜

Signed-off-by: Guilherme Cassolato <[email protected]>
Copy link
Contributor

@KevFan KevFan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified both envoy-gateway.md and multiple-gateway-providers.md are working as expected.

Looks good to me 👍

@guicassolato guicassolato merged commit 115a1ba into main Jul 29, 2024
4 checks passed
@guicassolato guicassolato deleted the reconciliation-workflows branch July 29, 2024 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants