-
Notifications
You must be signed in to change notification settings - Fork 15
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
Celery Kubernetes Operator CEP #1 #29
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, technically.
I'll review most of the style later as this CEP needs to be formatted according to the template.
draft/celery-kubernetes-operator.rst
Outdated
|
||
|
||
Scope | ||
===== |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style nitpick:
Our template includes all primary headings for every CEP.
If you have other headings, they should be included in one of the sections defined by the template.
CRD, controller and KEDA together(More to be explored here). We'll also | ||
support YAML apply based deployments. | ||
|
||
Additionally, Helm approach is extensible in the sense that we can |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My intention is for the Controller to deploy and manage the brokers too if it is possible in the platform Celery is being deployed on.
We should consider including their respective k8s operators in this operator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that makes sense. I'm yet to explore on that part.
Operators are a relatively new concept and very few are stable and maintained actively by the respective organization. I'm planning to read some failure/downtime stories for some insights on where operators go wrong. It'll help in being careful with what we're shipping with Celery operator.
draft/celery-kubernetes-operator.rst
Outdated
|
||
|
||
Motivation & Rationale | ||
====================== |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are two different sections according to the template.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'll update the proposal to strictly reflect the template.
draft/celery-kubernetes-operator.rst
Outdated
|
||
|
||
TODOs for Exploration | ||
===================== |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should include a section in the template for future work.
It's a good idea.
draft/celery-kubernetes-operator.rst
Outdated
- Helm chart to install the operator along with a broker of choice | ||
- Add role based access control section for the operator | ||
- Ingress Resource | ||
- KEDA Autoscaling Implementation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy to help with this one. Currently, we implemented APIMetricScaler
in KEDA which allows users to use any arbitrary API for scaling (for example Flower API): https://keda.sh/docs/2.0/scalers/metrics-api/
I personally had a good experience with using KEDA to scale Celery.
I see that the proposal suggests using KEDA for autoscaling and I think this a good idea. That's what we use in Apache Airflow official helm chart for autoscaling Celery workers. However, there's one thing to remember when scaling down the number of celery workers: https://www.polidea.com/blog/application-scalability-kubernetes/#tips-for-hpa |
Is there a way to notify Kubernetes to extend the pod's termination grace period? |
@thedrow users can adjust this parameter in pod definition. But this will differ from use case to use case. One possible hack is to set it to infinity and then terminate pod using preStop hook - but it's a hack and may affect cluster behavior. That was the main problem we had in Apache Airflow: tasks executed on Celery workers can take arbitrary long time (from seconds to hours). Here is a discussion about this problem and workarounds from Kubernetes community: |
draft/celery-kubernetes-operator.rst
Outdated
|
||
This project attempts to solve(or automate) these issues. It is aiming to bridge the gap between application engineers and infrastructure operators who manually manage the celery clusters. | ||
|
||
Moreover, since Celery is written in Python, we plan to use open-source `KOPF <https://github.com/nolar/kopf>`_\ (Kubernetes Operator Pythonic Framework) to write the custom controller implementation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moreover, since Celery is written in Python, we plan to use open-source `KOPF <https://github.com/nolar/kopf>`_\ (Kubernetes Operator Pythonic Framework) to write the custom controller implementation. | |
Moreover, since Celery is written in Python, we plan to use open-source `KOPF <https://github.com/nolar/kopf>`_\ (Kubernetes Operator Pythonic Framework) to write the custom controller implementation. |
It seems that the original project was abandoned: https://github.com/zalando-incubator/kopf And the fork seem to be maintained by a single person (at least 1 person did 95%+ of commits in last month). I'm not sure if it is a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can collaborate with https://github.com/nolar/kopf as well, though your concerns are valid. we usually try to offer a helping hand to the projects we rely on. I like the Kopf though O:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nolar wrote a detailed post on the same - https://medium.com/@nolar/kopf-is-forked-cdca40026ea7
He plans to continue the development on nolar/kopf
in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we usually try to offer a helping hand to the projects we rely on
That was also my thought, yet it's more to maintain and more to learn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for mentioning and for your support! ;-)
The previous (original) repository was maintained by one single person too (the same person, actually — me), so there is no big difference with the fork. The 95% commits in the last month is what actually was in my WIP repo for the past year, just finished, tested, pushed, and merged.
Regarding the project maintainability: the plans are to start building a community asap, probably even in 2020 (though, most likely, in 2021). But with zero knowledge on how to do that, this looks like a challenge — I'm reading articles on that now; and trying to choose a name which is not used on GitHub yet. Another option is joining one of the existing communities/organizations with established workflows — needs a comparison of pros & cons. This is something on my table to solve after the current backlog of urgent and pending things is done. But these plans are too fuzzy and uncertain to even mention them in the blog post.
This might be beneficial for the project both short-term, as it gets the boost, and long-term, as it does not become abandoned/unmaintained again.
I hope, this clarifies the future of Kopf for your decision making. If you have any questions — feel free to ask.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apache Software Foundation has an incubator for early projects http://incubator.apache.org . I think going this way has an advantage of established "ways of doing things" (20+ years). I recommend this talk https://www.youtube.com/watch?v=mD0Lh7si5Hc&t=2s
CNCF has an idea of "sandbox projects" https://www.cncf.io/sandbox-projects/ but I'm not that familiar with this one but from what I see (from KEDA) the projects are more on their own than in ASF.
I'm happy to help 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is description of incubation processes:
- ASF http://incubator.apache.org/cookbook/#what_are_the_steps_to_becoming_an_apache_software_foundation_top_level_project
- CNCF https://github.com/cncf/toc/blob/master/process/project_proposals.adoc
@nolar let me know if you would like any help (I'm already PMC of Apache Airflow).
@thedrow I've updated the CEP to strictly reflect the template. Kept the Future Work section as it is since you mentioned it'll be good to have. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've read the entire document now that I've released Celery 5 and I have a little bit more free time.
Overall, this is good work.
There are a few things I'd like you to address:
- Operator should be aware of the number of processes/greenlets the worker is running and must make autoscaling decisions based on that.
If we use greenlets, we only utilize one CPU per process and our main resource is I/O.
Further work could be done there when calium or another network management platform is installed. We should investigate this further.
If we use the prefork pool, we should count the number of workers to calculate concurrency. - We may wish to connect to various Celery signals to notify Kubernetes of certain events which we can handle.
For example if we didn't execute a task for a certain amount of time and there are messages in the queue, we may wish to terminate the worker as it is malfunctioning.
Another example is an internal error in Celery.
This requires a Python library. - The CEP should address how the operator intends to install the message broker/results backend.
This can possibly be done using the app's configuration. I think that this is a feature we want to implement at this stage for RabbitMQ and Redis.
Support for other components can come on demand.
We'll be doing this for Celery 5 anyway so it's worth investigating it now. - I'd like you to invest a little bit more time on coming up with new features. Your feedback is most valuable.
Thanks for reviewing in detail. I'll get back on these comments with some questions/inputs as soon as I can. |
Yeah. So in the case of the prefork pool, we could calculate the number of worker pods by taking into account min of CPU cores and concurrency value set by the user. For Solo, we can only increase the number of pods I think. For greenlets, we could accept the min and max concurrency values from CRD, similar to what celery already does, and only update the concurrency setting until we reach the threshold value specified for the workers. Beyond that, we'll increase the number of pods directly. That said, I'd have to look into how operator could take care of this custom logic along with KEDA/HPA scaling implementation. Also, I've not worked with Cilium yet, I'll explore it as well.
Do you mean these signals?
And yes, we should do this. I'll read more on all the signals and update the proposal with the ones we could handle. One additional thing I had in mind apart from examples you gave is implementing a simple kind of backpressure protocol, in case one of the components is overwhelmed, we emit certain events and propagate them back to the application or the starting point.
Can you please elaborate a bit more on this?
Yes, that makes sense. I did some exploration on how can we go forward with installing Redis/RabbitMQ cluster once Celery CR is created. The zero version solution could be simply to package the simple A more scalable approach would be to use the standard helm package manager. The general idea is to decouple the installation/management of Redis/RMQ from the handlers taking care of celery workers. I found the actively maintained helm charts by Bitnami for Redis and RMQ. However, the catch here is that Python handler taking care of creation/updation needs to somehow notify the Kubernetes to install the chart using helm. One way I thought of is that we also bundle helm operator with our operator. We then create a resource that this operator understands from our handler and it takes care of the rest. I'd like to discuss on the pros and cons of this approach. If someone has a better idea, I can explore it further.
Yes! One additional thing operator could do is to handle the dev, test and production sandboxes as well for the given CR specification. We could use Kustomize for the same. On a side note, I personally/or my company has not been a power user of Celery as such. We use really basic things so my knowledge is limited. But, I'm willing to explore and learn more on Kubernetes & Celery fronts. I feel Celery is awesome and at the same time a huge project to understand ins and outs of. Are there any places I can read more about how people use Celery in production? For now, I'm gonna go ahead and try to read whole documentation of Celery to filter out some use-cases operator could take care of. |
Sorry, I couldn't be active this past month. I'm still working on my knowledge of distributed systems in general. @thedrow let me know your inputs for my comment above whenever you can and I'll update the proposal accordingly. |
For some use-cases of ours the ephemeral storage is quite important too, not just CPU and memory as some of our tasks are heavily using this feature of AWS for an example... So, it is important to be flexible with parameters that could affect autoscaling. On a side note - It would be nice if Celery had cluster scaling API that we could "just" implement... |
We're working on it. See #27. |
@Brainbreaker I was extremely busy with Celery 5 myself. I think this PR is a fine first draft and we can merge it. |
Created an issue with open points. We can continue the discussion there on those points. |
@thedrow Couple of things around next steps to start development - I'm assuming we'll be making a new Github repository for celery operator under celery org. How does that process work? I've been through the contributing guide. However, let me know if are there any particular things you have in mind specific to this project's execution. As a first step, I can come up with a detailed subtasked plan and approximate timelines. |
We can move the prototype repo to the organization. |
Great. I'll have to be part of the celery organization for that. |
This PR adds a draft CEP for Celery Kubernetes Operator. For now, it is written keeping Celery 4.X in mind.
It is ready for the first round of reviews by maintainers.