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

Add --watchers flag to allow controller to respond automatically to Ingress or Service updates #687

Merged

Conversation

jlamillan
Copy link
Contributor

@jlamillan jlamillan commented Aug 24, 2018

This change is related to issue #484. It builds on this pull-request, and introduces a new flag called --events that when enabled, adds the controller's Run function as the event handler so that it's automatically called when a Service and/or Ingress are updated. Note that these "event" driven calls are complementary to the regular polling calls that occur every --interval. For example, we are experimenting with using --events as a way to increase our --interval while still being able to process updates to Services and Ingresses quickly and using the interval to handle of band changes every hour or so.

Some other notes:

  • On start-up, the Informers perform an initial list operation. A BoundedFrequencyRunner is being used to wrap the handler to limit calls to RunOnce generated by events and to avoid a call to RunOnce for every Service/Ingress on initial startup.
  • Similarly, the resync-period of the Informer is currently being set to 0 to further avoid any unnecessary call-backs from the SharedInformers unless a change has occurred. We can continue to rely on --interval to handle regular syncs since not all sources support events.
  • When --events is specified, any k8s client timeout is disabled to avoid periodic warning messages of timeouts that are caused by the persistent HTTP connection mechanism the informers use.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 24, 2018
@jlamillan jlamillan force-pushed the jlamillan/add_watch_flag branch from 95323c6 to f8b3ddf Compare August 24, 2018 01:35
@linki
Copy link
Member

linki commented Aug 30, 2018

@jlamillan Thanks for the pull request. We'll look into it.

@jlamillan jlamillan force-pushed the jlamillan/add_watch_flag branch from f8b3ddf to 068de95 Compare September 7, 2018 18:44
@jlamillan
Copy link
Contributor Author

Thanks @linki.

Rebasing my your branch onto the latest...

@jlamillan jlamillan force-pushed the jlamillan/add_watch_flag branch 4 times, most recently from e93584a to f0a931a Compare September 7, 2018 21:56
@jlamillan jlamillan force-pushed the jlamillan/add_watch_flag branch from f0a931a to de83bcb Compare September 25, 2018 22:31
@jlamillan
Copy link
Contributor Author

Re-based again. @linki eagerly awaiting your thoughts and feedback here. We've been using this change for awhile and it's been working well for us.

@jlamillan jlamillan force-pushed the jlamillan/add_watch_flag branch 2 times, most recently from 8ae3e21 to eed4ed0 Compare October 30, 2018 22:15
@jlamillan jlamillan force-pushed the jlamillan/add_watch_flag branch from eed4ed0 to 384e95e Compare November 7, 2018 22:27
@jlamillan jlamillan force-pushed the jlamillan/add_watch_flag branch from 384e95e to 0f03d33 Compare December 21, 2018 21:48
@jlamillan
Copy link
Contributor Author

/assign @Raffo

@Raffo
Copy link
Contributor

Raffo commented Dec 27, 2018

I got no bandwidth for this right now, I have to push it to the new year (likely CW2, CW3). If someone wants to review this first, please go on.

@lbernail
Copy link

We'd be really interested in using informers too: in our mid-sized clusters (~1000 nodes, ~1500 services, ~1500 endpoints), generating endpoints takes ~5mn (the current code perform a lot of list pods calls, because we use headless services, which are heavy ones for the apiservers)

If I understand the PR correctly, it just uses Informers to trigger a sync loop on events. What would be even better is to use the informer cache to store services and pods (and, yes possibly trigger a sync on update).

In addition, using the pod objects is very inefficient compared to using endpoints (in which case we could native rely on pod Readiness instead of looking at the pod phase). If I understand correctly, we use pods for the publishHostIP case. Maybe we could use endpoints in general and fallback on pods for this specific use case?

@jlamillan
Copy link
Contributor Author

What would be even better is to use the informer cache to store services and pods (and, yes possibly trigger a sync on update).

Good idea, I'll adjust the PR soon...

@lbernail
Copy link

lbernail commented Feb 3, 2019

Great, I can help if needed (and will definitely test)

Another idea would be to have a resync period (to avoid getting in an inconsistent state over time) but to use a BoundedFrequencyRunner for the main sync function to avoid running it if it was run less than X seconds ago (kube-proxy works like that for instance)

@jlamillan jlamillan force-pushed the jlamillan/add_watch_flag branch 2 times, most recently from 27ccc45 to 0fb60fb Compare February 19, 2019 23:54
@jlamillan jlamillan changed the title Add --watchers flag to allow controller to respond automatically to Ingress or Service updates WIP: Add --watchers flag to allow controller to respond automatically to Ingress or Service updates Feb 21, 2019
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 21, 2019
@jlamillan jlamillan force-pushed the jlamillan/add_watch_flag branch 3 times, most recently from 634a0d7 to 02a8045 Compare February 21, 2019 20:32
@jlamillan
Copy link
Contributor Author

@lbernail, check out this branch, which updates ingress and service sources to use the informer cache instead of making API requests for ingresses and services/pods/nodes, respectively.

If that change looks good, I could possibly submit that as a separate pull-request and use this pull-request to subsequently add the ability to have informers to trigger a sync loop on events via --events flag.

i.e.

commit 1: Use k8s informer cache instead of active API server calls in ingress...
commit 2: Add --events flag to use k8s informers to automatically trigger sync loop…

@jlamillan
Copy link
Contributor Author

/unassign @Raffo

@jlamillan
Copy link
Contributor Author

/assign @njuettner

@njuettner
Copy link
Member

@jlamillan do you mind fixing the conflicting files and then I'm happy to merge it.

@jlamillan jlamillan force-pushed the jlamillan/add_watch_flag branch from 29cc70e to e5d8857 Compare November 20, 2019 21:34
@jlamillan
Copy link
Contributor Author

jlamillan commented Nov 20, 2019

Done @njuettner.

As a reminder - --events defaults to false. At some point, we should consider to having it default to true.

@SEJeff
Copy link

SEJeff commented Dec 5, 2019

@jlamillan can you fix the conflicts?

@jlamillan jlamillan force-pushed the jlamillan/add_watch_flag branch 2 times, most recently from 7e735a0 to 29018c2 Compare December 6, 2019 19:53
@jlamillan
Copy link
Contributor Author

@jlamillan can you fix the conflicts?

done.

@njuettner
Copy link
Member

@jlamillan sorry again, do you mind fixing the conflicts again?

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 9, 2020
@jlamillan jlamillan force-pushed the jlamillan/add_watch_flag branch from 29018c2 to c324019 Compare January 10, 2020 20:21
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 10, 2020
@FrederikNJS
Copy link

@njuettner: It seems that this has been rebased, and is ready to be merged. It would be a bit of a shame if @jlamillan would have to rebase again a 7th time.

@johanneswuerbach
Copy link

Sorry for the nudge @SEJeff / @njuettner , but we are also really looking forward to see this merged.

@jlamillan
Copy link
Contributor Author

jlamillan commented Jan 21, 2020

Looks like the RunOnce signature was updated the other day. Resolving conflicts, rebasing, and testing...

@jlamillan jlamillan force-pushed the jlamillan/add_watch_flag branch from c324019 to 15c73f5 Compare January 22, 2020 00:25
… on adds/updates/deletes for supported ingress and service sources.
@jlamillan jlamillan force-pushed the jlamillan/add_watch_flag branch from 15c73f5 to fed2f0f Compare January 27, 2020 19:20
Copy link
Member

@njuettner njuettner left a comment

Choose a reason for hiding this comment

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

lets merge it @jlamillan. thank you again for contributing, much appreciated!

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 4, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jlamillan, njuettner

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 4, 2020
@k8s-ci-robot k8s-ci-robot merged commit d49d901 into kubernetes-sigs:master Feb 4, 2020
lou-lan pushed a commit to lou-lan/external-dns that referenced this pull request May 11, 2022
* Most of the changes for the user-guide section

* Add follow up changes to user guide section
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants