git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A "Kamel" crazy idea


It's clear to me that we need to add support for our existing XML DSL, that
is powerful. But there are multiple reasons why I'd like to also "add" a
limited yaml/json notation to "Kamel".

The first one (and simplest) is that json/yaml is the primary encoding for
all resources exchanged with the Kubernetes API server. I'm not saying that
for this reason the Integration resource cannot contain a XML
(/Java/Ballerina) section, but from a pure presentational point of view,
having the possibility to write simple use cases (even a "hello world") in
pure json/yaml is better than always requiring a mix of json and XML.

The second one is simplicity. Writing a optimizer (the module that
materializes the integration into running code, choosing a specific runtime
and configuration) for a turing-complete language like Java is not easy:
even if you manage to create a good parser, it may be able to do
optimizations only if you write routes in a particular way, without complex
constructs.
XML is ok from this point of view. The thing is that both json/yaml and XML
are just two different ways to serialize object trees, that can be then
statically analyzed.
The point is not XML vs json/yaml, it's more about tailoring a new
minimalistic DSL to the emerging use cases vs proposing "only" our classic
way of writing integrations. I think XML can be the "advanced" way. We can
experiment optimizations easily with the new DSL, and enable them also on
XML if it's worth.

Scripting should be part of the spec, but I'd try to use programming
languages only for processing/transformation, not for the route definition.

Third one is performance. Apart from the fact that json parsers are in
general said to be faster than XML parsers... Given the "fast startup"
target that we want to reach, we may think e.g. to translate the new DSL
into Java or Go code, then compiling it. This allows doing parsing at build
time in order to avoid it on startup. This kind of improvements are much
easier with a limited DSL but much more difficult with a existing
fully-fledged DSL..

Nicola



On Wed, Jul 18, 2018 at 11:51 PM Pontus Ullgren <ullgren@xxxxxxxxx> wrote:

> I also like the idea but with some comments.
>
> As Hiram Chirino I'm not sure YAML/JSON is the best language for this.
> Perhaps a more fluent DSL like the Camel Java DSL or perhaps something like
> Ballerina language would be better suited ?
> Also in my experience even simple integrations, that is simple real world
> integration and not just hello world demos, requires
> you to add one or more Java class or scripting in addition to the core
> components. So for it to be useful there must be some way to add custom
> code in some way for aggregation/enrichment strategies.
>
> If you go with a GO implementation I would also like some fallback for
> using Java since I find it unlikely that the existing base of components
> will be ported any time soon.
>
> As for the name as other I like the "Kamel"  name however a being a newborn
> kotlin fan I know of one pre-existing project with that name
> that is close enough to allow for potential confusion.
> https://github.com/topicusoverheid/kamel
>
> Looking forward to see the result.
>
> // Pontus
>
>
>
>
>
>
> On Mon, 16 Jul 2018 at 15:15 Hiram Chirino <hiram@xxxxxxxxxxxxxxxx> wrote:
>
> > Love the idea.
> >
> > Personally, I'd keep using the existing Camel XML DSL if possible.  You
> can
> > still embed it in the CRD.  The operator that deploys it could inspect it
> > and figure whats the most optimized runtime that can support the DSL.
> > Perhaps if it's only using the restricted set of camel components
> supported
> > by camel-go (https://github.com/lburgazzoli/camel-go) then is uses that.
> > Otherwise it falls back to using camel spring boot.
> >
> > For that to work I think we need the different runtime implementations to
> > provide a way to ask them: 'hey do you support running this camel route?'
> > Not a trivial thing to respond to, it might require a build step in there
> > for traditional Camel runtimes.
> >
> >
> > On Fri, Jul 13, 2018 at 4:32 AM Antonin Stefanutti <
> antonin@xxxxxxxxxxxxx>
> > wrote:
> >
> > > Hi Nicola,
> > >
> > > I love the idea.
> > >
> > > I just wonder whether YAML/JSON is an expressive enough format in the
> > long
> > > term. But as you’ve mentioned, starting simple would enable
> experimenting
> > > some very interesting / promising optimisations. So it seems worth
> taking
> > > that path, instead of trying to embed a complex DSL or the existing XML
> > DSL
> > > into the CRD.
> > >
> > > Definitely +1
> > >
> > > > On 13 Jul 2018, at 01:30, Nicola Ferraro <ni.ferraro@xxxxxxxxx>
> wrote:
> > > >
> > > > Hi Cameleers,
> > > > it's now passed some time since I started thinking about a new
> project
> > > that
> > > > we can begin here at Apache Camel, and I'd like to have your opinion.
> > > >
> > > > We've already been targeting cloud-native applications with Camel,
> > > > especially on top of Kubernetes, that is becoming "the standard"
> cloud
> > > > platform. But writing a Camel integration and running it on
> Kubernetes
> > > > requires some effort: choosing the base platform (spring-boot, karaf,
> > > > simple main?), adding health checks (actuator?), packaging a docker
> > image
> > > > and creating the Kubernetes resources (fabric8-maven-plugin, helm?),
> > > > publishing the image on a docker registry, then finally deploying the
> > > > resources on a Kubernetes cluster.
> > > >
> > > > The resulting integration container is then far from being optimal
> > from a
> > > > resource consumption point of view: it is likely that a Camel
> > Spring-Boot
> > > > application will require at least 200MB of RAM and also some CPU
> shares
> > > > because of polling threads used by many components.
> > > >
> > > > In case people use a CI/CD pipeline, it will take also a long time to
> > get
> > > > from a code update to having a Kubernetes POD up and running.
> > > > Apart from compilation and image push/pull time, also startup time is
> > > often
> > > > ~10 seconds for Camel + Spring-Boot in a container with standard
> limits
> > > on
> > > > resources, making it difficult to propose this combination for
> > > "serverless
> > > > integration" (this term is becoming increasingly more popular).
> > > >
> > > > So, my proposal is to start to investigate a "more cloud-native"
> > approach
> > > > to integration: *making Camel integrations first-class citizens in
> > > > Kubernetes, and making them super fast and lightweight.*
> > > >
> > > > We can base the project on Kubernetes Custom Resource Definitions
> (CRD)
> > > > <
> > >
> >
> https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/
> > > >,
> > > > for example a Integration CRD and have a Kubernetes "operator"
> > > > <https://coreos.com/operators/> taking care of:
> > > > - Optimizing the integration that we want to run
> > > > - Packaging in a container
> > > > - Running it on Kubernetes
> > > > - Managing its entire lifecycle
> > > >
> > > > A Kubernetes-native integration may look like:
> > > >
> > > > -------------------
> > > > kind: "Integration"
> > > > apiVersion: "camel.apache.org/v1alpha1"
> > > > metadata:
> > > > name: "example"
> > > > spec:
> > > > replicas: 1
> > > > routes:
> > > >  - id: timer
> > > >    route:
> > > >     - type: endpoint
> > > >       uri: timer:tick
> > > >     - type: endpoint
> > > >       uri: log:info
> > > > -------------------
> > > >
> > > > For those who are not familiar with Kubernetes resources, this kind
> of
> > > > YAML/JSON resource definitions are really common.
> > > > The example route is embedded in the Kubernetes resource declaration
> > and
> > > > follows a basic "flow DSL". We may start from a basic one and evolve
> it
> > > as
> > > > new requirements arrive from the community.
> > > >
> > > > I've made a very simple (but working) POC here:
> > > > https://github.com/nicolaferraro/integration-operator.
> > > >
> > > > This idea of a "Cloud-Native Camel" on Kubernetes (project codename
> can
> > > be "
> > > > *Kamel*", if you like it :D), will be an enabler for a lot of nice
> > > features.
> > > >
> > > > For example, we can propose "Kamel" as "ideal" platform for
> "serverless
> > > > integration" (I see many people reinventing the wheel out there): the
> > > > operator can reduce resource consumption of a single integration by
> > > > optimizing the runtime and also pause/resume integrations when they
> are
> > > not
> > > > used, that is the basic idea behind "serverless" (e.g. think to
> > > > HTTP-triggered integrations, but not only).
> > > > Focusing on serverless will bring more emphasis on push-based
> > > notifications
> > > > (webhooks, cloud events <https://cloudevents.io/>), that are rarely
> > > used in
> > > > Camel components, that prefer a poll based approach being it simpler
> to
> > > use
> > > > in classic deployments, but not so good in the cloud, where more
> > > resources
> > > > become higher direct costs for the users.
> > > >
> > > > The presence of the simplified DSL enables also experimenting on
> > > "*reduced*
> > > > subsets of Camel" implemented in languages other than Java, for
> example
> > > one
> > > > language that has a reactive approach on thread scheduling and a
> really
> > > low
> > > > memory footprint, like Go.
> > > >
> > > > But apart from this kind of experiments (that are valid IMO), the
> > "Kamel"
> > > > optimizer will have free room to choose the right platform for the
> > > > integration that the user wants to run, including, in the future,
> doing
> > > AOT
> > > > compilation using Graal/VM (less memory, faster startup) if the
> > features
> > > > (components) used in the integration are supporting it (maybe we can
> > add
> > > > AOT compilation in the roadmap for Camel 3).
> > > > A silly optimization: integrations starting from "timer:..." may be
> > > > scheduled directly with Kubernetes CronJobs, so they will consume
> > > resources
> > > > only when actually running.
> > > >
> > > > Being the final integrations lightweight and being the DSL
> > > > language-independent, we may see a increased adoption of Camel also
> as
> > > > agile integration layer for not-only-java applications (both "cloud"
> > and
> > > > "serverless" applications).
> > > >
> > > > I'm the first one that would like to work on a project ilke this.
> I've
> > > > worked on many Kubernetes/Openshift based applications and frameworks
> > in
> > > > the past years, also on operators and CRDs, and I think this way of
> > > > redesigning integrations has a lot of potential.
> > > >
> > > > Integrations will not be necessarily limited to the simplified DSL,
> but
> > > we
> > > > can add extension points for scripting and even custom libraries
> > > (although
> > > > limiting the freedom of the optimizer).
> > > >
> > > > The most important thing: it may become a great project, since it's
> > > driven
> > > > by a great community.
> > > >
> > > > So, what do you think? Is it crazy enough?
> > > >
> > > > Nicola
> > >
> > >
> >
> > --
> > Hiram Chirino
> > Engineering | Red Hat, Inc.
> > hchirino@xxxxxxxxxx | fusesource.com | redhat.com
> > skype: hiramchirino | twitter: @hiramchirino
> >
>