Comments (3)
Quite interesting topic. Want to hear feedback as well.
from kopf.
@Brainbreaker Sorry for slightly late response for almost a week.
Yes, using either daemons or timers is the right way to do this task. They were actually designed for the purpose of monitoring something "outside", i.e. for this exact purpose.
Depending on whether the remote system can do "blocking" long-running requests (like K8s's own watching), it could be daemons. If it cannot — which I expect for the majority of the systems — timers are better, they save a little bit of RAM for you.
Timers are also better for another reason. When a remote system provides some metrics, you can put them into the resource's status via the patch
kwarg (patch.status['smthng'] = value
), and it will be applied to the resource once the timer function is finished. On every timer's occasion. For daemons, you have to apply that yourselves (because daemons never exit, kind of). Not a big deal, but can be convenient.
There is one aspect you should work out in advance: the error handling. If updating of a deployment fails, what should follow? In theory, timers are retried with backoff=60
(seconds; configurable; not the same as interval=…
), so everything might be okay and as expected. But maybe you do not want to poll the remote system too often on every retry, so you would want to store the retrieved metric on the resource into a field .status.m
, and modify the attached deployment in the on-update/on-field(field=status.m) handlers separately. But these are low-level details, actually. And over-complication based on assumptions.
Let me know if it works for you. If there are any confusing moments in using timers/daemons for this exact task, they'd better be fixed & clarified in the framework.
from kopf.
@nolar Thank you so much for the detailed response.
Yes, using either daemons or timers is the right way to do this task. They were actually designed for the purpose of monitoring something "outside", i.e. for this exact purpose.
Got it.
Depending on whether the remote system can do "blocking" long-running requests (like K8s's own watching), it could be daemons. If it cannot — which I expect for the majority of the systems — timers are better, they save a little bit of RAM for you.
Makes sense. Thanks for mentioning this.
Timers are also better for another reason. When a remote system provides some metrics, you can put them into the resource's status via the
patch
kwarg (patch.status['smthng'] = value
), and it will be applied to the resource once the timer function is finished. On every timer's occasion. For daemons, you have to apply that yourselves (because daemons never exit, kind of). Not a big deal, but can be convenient.
There is one aspect you should work out in advance: the error handling. If updating of a deployment fails, what should follow? In theory, timers are retried with
backoff=60
(seconds; configurable; not the same asinterval=…
), so everything might be okay and as expected. But maybe you do not want to poll the remote system too often on every retry, so you would want to store the retrieved metric on the resource into a field.status.m
, and modify the attached deployment in the on-update/on-field(field=status.m) handlers separately. But these are low-level details, actually. And over-complication based on assumptions.
These are actually good insights that I couldn't think of in the first go. Thank you for sharing this. I'm going to try out Timers for this task and report back anything I'm confused about/need help with. Would be willing to improve documentation too if needed.
from kopf.
Related Issues (20)
- Force-kill the operator from inside if stuck at exiting HOT 1
- Resource grows too big with multiple operators for same resource HOT 5
- Watch for changes in array items.
- Resources filtered out in event handlers still get annotated by Kopf HOT 1
- Field handler is trigger even if the field does not exist in the resource at the time. HOT 2
- Question: run-time registration of handlers? HOT 2
- Is there any real world use of kopf,like rook/ceph? HOT 3
- Root task 'watcher of kopfexamples.zalando.org' is failed: 403, message='Forbidden' - EKS HOT 2
- Can't apply turtorial crd.yaml example,The CustomResourceDefinition "ephemeralvolumeclaims.zalando.org" is invalid HOT 1
- Creating a filter based on metadata.ownerReferences.kind == Statefulset HOT 1
- Subhandler states are not cleared at the end of handling cycle HOT 3
- All handlers succeeded for creation despite raising kopf.HandlerFatalError HOT 3
- Docs use wrong name for kopf.AnnotationsDiffBaseStorage HOT 1
- @kopf.timer continues to run after CR is deleted HOT 2
- client_timeout on watch results in a fatal error HOT 1
- AttributeError: 'NoneType' object has no attribute 'loader' HOT 1
- Reload / Restart all Kopf handlers when a configmap changes.
- Dedicated channel for asking questions regarding kopf usage?
- Exceptions for kopf on event for network connectivity delayed / issues
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kopf.