SeanCheatham / cloudstation

An unofficial IDE for CloudState.
1 stars 1 forks source link

CloudStation k8s Operator #1

Open SeanCheatham opened 3 years ago

SeanCheatham commented 3 years ago

Implement a Kubernetes Operator which manages CloudStation projects within a cluster. The operator should not duplicate the efforts and functionality of the CloudState operator; it should instead complement it.

The CloudStation Operator is responsible for:

sleipnir commented 3 years ago

Let me try to understand this here. Are we going to have some type of CRD that the user will generate? I often see operators used to monitor CRD deployments, how will this work with CloudStation? Another question is how after the user defines his logic via the frontend we will generate the artifacts for the user's specific language? There must be a stage of building these files for the desired programming language and subsequent generation of the docker image and publication in the user's registry, right? Do you already have any idea how to do this? Maybe, and only maybe, we should use some tool similar to the CloudState Community CLI that can generate the real project in the end. What language and/or framework do you want to create the Operator with? With Go, Quarkus, Scala?

SeanCheatham commented 3 years ago

All good questions that are still TBD! But where I'm currently leaning:

My hope, as far as "backend" goes, is to actually implement as much as I can using CloudState itself. So for example, I got started on a "Project" Event Sourced Entity that keeps track of Project state (models, event sourced entities, replicated entities, and actions). For the step where CloudStation needs to build and deploy to Test, I was hoping to use CloudState Actions to handle that process. There would be one Action per supported language (so a CloudState Action meant specifically for generating/building/compiling for Java, another for JavaScript, another for Dart, etc.)

As far as language choice for the k8s Operator - this is new territory for me personally. I'm familiar with what Operators and CRDs are and have used them, but I have 0 experience actually building them. In that light, I would personally choose Scala to implement the operator since it's my most familiar language. But I see they are frequently implemented in Go so I may end up learning a new language.

sleipnir commented 3 years ago

I specifically liked the idea of using CloudState itself to generate some steps in the process. Regarding the Operator I can make a prototype in Kotlin / Quarkus Native, that would be quick, I'm not a big fan of Scala for native compilation and I think Quarkus has all the tools for building an operator built in so I can try to go that way if you want help.

SeanCheatham commented 3 years ago

I hacked together some rough backend implementation code. I think we can make it so the CloudState CLI does most of the heavy lifting like you suggested. I think we can simplify down several of the steps I listed above into create -> build -> deploy using the CLI. The rough (and incomplete) implementation I have so far is an Action written in Dart. The Action's main purpose is to transform the internal model into actual code, but its other purpose is to invoke the CloudState CLI create, build, and deploy commands.

I'm actually wondering - if we lean on the CloudState CLI heavily enough, we may not even need a CRD. If the "Deploy CloudStation Project" Action interacts with the CloudState CLI which interacts directly with CloudState, then a CRD may not be necessary.

I think perhaps instead of an operator, this could all be simplified down to a Helm chart that does the following:

This is all just brainstorming though. Any thoughts on that?

sleipnir commented 3 years ago

I think we can have some quick success that way but I will need to invest some time in the CLI again because it is downtime. Another thing I can do is expose the CLI's functionality in the form of API's so we would deploy something like cloudstate --server in a container and install it in the cluster via HELM as suggested and it would react to your action. A question how did you use Action with Dart?