Transcript
This transcript was autogenerated. To make changes, submit a PR.
Hello, everyone.
Welcome to Conf42 and welcome to my session on ballerinas on lake,
which is, we are talking about code to cloud mastering communities
deployments with ballerina.
And I'm going to discuss about the code to cloud journey, the challenges, as
well as how application development and also the deployments can be
simplified by using ballerina.
First of all, let me introduce myself.
I'm Anupama Pathiragi, currently working as director and head of engineering.
at WSO2 and I'm leading the development efforts of Ballerina as well as
the developer relations effort.
So without taking much time, Let's start the discussion.
So I thought of starting the conversation with this.
So this is an AI generated image.
You can see there's an application developer.
And also there are so many complexities around him when
it comes to the deployment.
There are cloud components and there are many different endpoints.
applications, services, which are connected together and also the
deployment aspects and the things were deployed in different places.
Then you might wonder why the application developer has to think
about all these things, whether the application development and deployments
are two separate things, but actually in the reality, it's not the case.
So the journey from code to cloud, we have to think about how applications
are developing When we think about the cloud as well, because with the
rise of the cloud native applications, things have evolved and transformed
actually how we build applications as well as how we deploy the applications.
In the modern application developments, we need integrations.
It's an unavoidable part because we have to talk to multiple different
services, endpoints, and having seamless integration is key thing.
And also scalability aspects and reliable deployment strategies.
All these are key components in application development
in the modern world.
So Kubernetes has emerged as a standard for gestating the complex cloud
deployments and also it's simplifying most of the deployments and almost everything.
So this process like planning the application, Implement it, build it,
test, release, deploy, operate, and finally monitor, all these are connected
and there should be seamless process.
That's why we say cloud code to cloud is very important when it comes
to modern application development.
And also, although cloud deployments are comparatively easy, there are so many
challenges in the cloud integrations.
The first thing is multiple services.
Cloud integration means we have to involve or talk to different services
and interact with different APIs and those will have to work together.
And this inherent, complexity imposed by these services and data
formats protocols we have to handle.
And also the dynamic environments when it comes to the deployments
because cloud environments are highly dynamic with containers, autoscaling,
and also microservices, how the security is handled and so on.
And also the configuration overhead.
Managing deployment configuration is a key thing in the cloud deployments and
how we autoscale and how we monitor.
Those things can be time consuming if we have to manage
all these configurations manually.
And also the security compliance, ensuring the data is flowing securely and also
the compliance requirements are achieved.
Likewise, there are so many things when we, when we, when we think about
the cloud or integration applications.
So that means application development is not isolated.
We have to think about all these challenges as well as the
deployment aspects when designing and implementing the applications.
So in today's session, I'm going to discuss how ballerina can help you, with
this thing, not just the development and also the deployment aspects.
So first of all, what is ballerina?
In high level, it's technology for simplifying cloud integrations.
Let's look at a little bit more details.
So it's an open source cloud native technology, which is
optimized for integration.
In a way we can think of it as a programming language as well, but more
or less it's a platform for integration.
It's developed by WSO2.
It's an open source project, completely open source project.
And the first version is released.
in February 2022, which we called Paladin Aswan like version.
if you think about the key thing, key aspects, it has rich
ecosystem of different services, data formats, and connectors.
And also it has both textual representation as well as graphical
requisite representation as sequence diagrams and flowcharts, which is
very much helpful when it comes to maintainability of the application.
And also it has many safe to primitives, which helps the developers, for example,
efficient concurrency mechanisms.
The compiler itself can detect some data races during the compile time because it
is very difficult to handle these data races and, concurrency related problems
in the runtime because integration applications are inherently concurrent.
And if we had to deal with concurrency issues, it's not that easy.
Thank you.
So this is a brief overview about Valarina.
So let's look a little bit deeper.
So it's all about cloud native integrations.
And I said it's a programming language, but it's not just a programming language.
It's more than a programming language.
It's a full framework.
So if you compare it with other languages, many like C Java, Go, etc.,
Valarina syntax can fall into the same family of syntaxes.
We can think it's a programming language, but which is highly
optimized for, integration needs.
We can do any general purpose application development using Valerina,
but when it comes to integration application development, there are
so many abstractions and other, tooling capabilities and so on to
make the developer's lives easy.
So the abstractions are the important or playing key thing here.
right level abstractions, having the right level of abstractions is very
important because It will improve the developer productivity and
understandability of the code as well as the maintainability of the code.
And also this is not a research product and it's heavily used
in production environments and it's an open source product.
Anyone can freely use it as well.
There's a huge open source community around us and we
are working collaboratively with open source community.
So I say Balena provide the right abstractions for integration.
There are three levels, or three types, actually.
First thing is data.
When it comes to integration applications, data is a key thing,
because we have to represent data.
We have to think about different data types, formats, and how we
manipulate data, and how we communicate data from one service to another.
Likewise, data plays a key role.
So Valerina provides so many abstractions, data type support,
and type checking, serials.
semantics to make it easy and also the network representing the network, how
we define client, how we define service beyond different network protocols.
All these things should be very easy without going into
the very low level details.
The application developer should be able to get their network requirements done
very easily and also the concurrency.
As I mentioned before, the concurrency safety.
During the application development itself can be.
Very helpful, when it comes to integration applications.
So there are three stages mainly in the application life cycle.
First thing is the deployment and the maintenance.
And after that, we had to think about deployment aspects.
And finally, the monitoring or the runtime aspects.
So let's quickly go through all these things.
And I will showcase these in my demo as well.
But before that.
Let's go through some high level overview of all these aspects.
So if we look at the development and maintenance, what we are
talking about is a full life cycle of the application development.
Since ballerina is A language, we can use VS Code as the IDE
and with the familiar tool set.
So you can commit the source code to a preferred source control system
like GitHub, GitLab, whatever, and also can use existing CI, CD
processors and deployment can be done into any environment that you want.
And when it comes to the runtime aspects of monitoring, logging, et cetera, you can
connect your existing tools and systems.
to the running ballerina applications.
So if you think about how you start with ballerina first, you have
to create your ballerina package.
So there's a CLI associated with ballerina.
Once you install ballerina.
You can go to ballerina.
io website and get the download install installers of the ballerina distribution.
And once you install it, you can get the ballerina CLI.
With that, you can create new packages using ballenew command.
So these are like the big details.
I'm skipping those things as you can try those things by yourself.
And once you do that initial ballenew command, you will get a ballerina package.
Which contains the minimum set of files needed to identify
it as a package and run it.
So it contains bel files, which are the source code files.
So like any other programming language, these are the files
where you write your application.
And there are some other meta files like ballerina.
toml file.
Which identifies a given directory as a ballerina package.
It contains the metadata about the package, like the package name,
version, and many other information.
So this is like a structure of the package.
By looking at this, you should get the sense that, okay, this is like any other
programming language and how you start a project and how you start your application
development journey is very simple.
And then the next thing is how we design our application, especially
the integration applications.
In Ballerina, we have integration designers for the various protocols.
For example, REST based applications, you can start by defining services
and then defining resources and finally add the data types.
Return types and so on.
So here you can see the graphical view of the service designer.
You can use both code view or either code view or the graphical view.
Both will do the same thing and as per the convenience, or what
preference, you can select, either code view or the designer view.
So that is an easy mechanism for the initial skeleton development.
And same with GraphQL, you can design and visualize your GraphQL
applications using GraphQL designer.
Likewise, these service designers are very much helpful to start with
your application design process.
And after designing your application, the initial stages and the skeleton,
it is just a matter of developing your business logic accordingly.
So I mentioned about the graphical view.
And also for all the pro, any programming application, any application that you
are developing with ballerina, you will get visual representation as well.
That is in terms of sequence diagram, you can see a left hand side is
a code view, right hand side is a visual view or the graphical view,
which is the sequence diagram.
So without looking at the source code, you can understand everything
by looking at the sequence diagram.
As it says, there are two.
endpoints, GitHub and Google sheets.
And this application is getting some information from GitHub and then,
some from, Google sheets and writing to the Google sheet at the end.
So if your application is very complex or having a lot of source files, lines
of codes, going through each of them to understand who are the different
endpoint, what are the different endpoints, how we are going to interact
with each of them is very difficult task.
And with this feature, you can visualize your application without any additional
efforts because every application that you develop, you will get automatically,
you will get this diagram automatically if you are using the VS Code plugin.
So this is very important or very helpful when it comes to the understandability of
the system as well as, maintainability.
And also you can edit this diagram.
You can see plus buttons, in the diagram nodes.
Where you can add additional constructs as needed.
So if you prefer to continue in the diagram side, you can do it,
but most of the time developers prefer to use the code editing.
So if you edit the code, that will reflect in the diagram side.
And also documentation.
It plays a very important role in the application development and
especially enterprise application development because those applications.
are having complex code and also maintainability point of view those
applications should live longer.
So this matter, Bellarina supports Automatic documentation and you can
see the code comments get appended to the documentation of your
service or application and there is sophisticated documentation generation
Framework where you can convert the ballerina inline commands into
documentation of your application as API, document API specifications.
So this is an example view of how the commands got converted into the
application or the documentation.
And the other thing about data transformations, because in the
integration applications, we always have to deal with different data formats
like XML, JSON, CSV, and many different formats and also different, even from
JSON to JSON conversions or XML to XML conversions can be very time consuming
if you have very large payloads.
In Ballerina, we have data mapper, which is simplifying this process.
You can use.
you can load the left hand side and right hand side information from where to map.
To which, construct this is what we call record in Valerina.
We have a type called record in Valerina, which is the canonical representation
of all the data types like JSON, XML can be represented as records.
And then it's just a matter of mapping the record fields.
And also in between you can do multiple expressions at multiple expressions
to do additional calculations.
And you can map multiple fields into one fields like that.
without writing any line of code, you can visually map and
generate the code automatically.
The next thing is about debugging.
In application development, you always have to troubleshoot
your application code.
Then that's what we need, debugging.
Since Balogna is a programming language, you can always use usual debugging
capabilities comes with VS Code plugin.
And use the debugging functionalities like any other programming language.
Then since Balanizer is an integration technology, it comes with a
distribution which contains the support for all of these protocol types.
There are so many protocol types when it comes to integration applications.
We can, we have to deal with different types of applications, different
services, different clients, like gRPC, REST, GraphQL, WebSupp.
FTP and so on.
So Ballerina has support for all these protocol types and you can
define services or clients as needed using these protocol types.
Not only these protocol support, Ballerina comes with Ballerina library,
which contains library packages for utility functions like time, cache,
things like that, and also packages to support various protocols.
So all these things comes with the Ballerina distributions.
And you don't need to do anything explicitly to have
those things in your application.
Not, not just the connect app, library.
Then what we have is the connectors because integration application means
you always have to connect with different systems, different endpoints, SAS
applications, data services, and so on.
Belinda has more than 600 plus connectors, which can connect seamlessly with
these different types of systems.
And if there's.
A system which we already which we are not supporting at the moment Generating
a connector for such service also very easy We have open api tool which can
get an open api specification as input And then convert it to a ballerina
connectors within very short time.
And then the other thing is handling Data modeling and persisting is also
an important thing ballerina has module called persist, where we can
use it to model your data, like entity relationship diagram that you see here.
You can define the relationship between your entities and then it will
automatically map to different data types, data sources like databases.
Redis stores or maybe Google sheets, or in memory data types,
in memory data stores and so on.
It is like ORM that you can see in some other languages and this persist
capability is very important or very helpful when designing applications with,
which has data integration capabilities.
so far I have discussed so many visual capabilities as
well as tooling capabilities.
If I summarize this, we have various integration tools built with the
distribute inbuilt, in the distribution, like EDI tool, which can convert
various EDI formats into the other data formats and also open API tool to
convert a given open API specification to a service and vice versa.
And, GraphQL tool, health tool to work with various health
data protocols and formats.
Likewise, all the required tools or CLI commands are available with the
Ballerina distribution so that you can work easily with different data
formats, protocols without looking for alternatives or different external tools.
After application development, the next thing is about testing or else
you have to think about test when designing the application itself.
If you think about test driven applications, so
it's a very important thing.
And ballerina as a language support all the testing capabilities, you
can generate test reports and see the coverage numbers and so on.
So your application will not, behave unexpectedly if you have better tests.
Then the last thing is about AI capabilities.
Without AI, now we can't survive in the modern application development.
Balerna as a language has a GitHub Copilot support.
If you have GitHub Copilot, you can see the suggestions like this.
It is very much accurate and, Copilot is aware of Balerna syntax and so on.
And also we have inbuilt AI assistant.
Which can generate unit tests with copilot and also document the given Application
code which is very much helpful with the documentation aspects as well as
testing capabilities And also we have automap feature, which is also AI built
AI based thing which can map the left hand side of the construct of the record
into the right hand side Which is very useful in the data mapper When you are
mapping different data formats and types.
So those are some AI capabilities that we have introduced to make
the developer's life easier.
so far we discussed the development aspects and the maintenance aspects.
The next thing is about deployment, which is the key thing in
today's discussion as well.
deployment point of view, you can build a self contained jar by using
the build command, and then you can run it using the run command.
It will create a jar file executable, which you can use to run the application.
But when it comes to cloud deployment, Ballerina has designed in a way
that it allows the developers to write code without thinking
about the deployment platform.
So Ballerina developers don't need to worry about it because that is very much
too much complexity for the developers.
And that greatly simplifies the experience of developing and deploying
the application in the cloud.
You can use the Belknap commands and other tools to generate the required
cloud artifacts without much hassle.
So let's see how that is achieved.
You can create a docker image very easily using bel build command.
You can see dash cloud with the parameter docker.
It will create the docker file with all the required dependencies,
docker image, To use with your deployments and same with kubernetes.
You can use the same command with the kubernetes flag A parameter
and it will generate the kubernetes artifacts Where you can modify if
needed or you can use the cloud.
toml file to configure during the build time itself So the compile is aware
of the resources and other support definitions configurable variables
And other things available in your application code and will generate You
the deployment artifacts accordingly.
And then the final thing is about operation, how we handle things in
the runtime, but now support, all observable capabilities, including
metrics, tracing, and logging.
And it can be observable by any open or telemetry supported tools.
So these are some examples of metrics with Grafana, and this is tracing with Jago.
And distributed login also supported with that.
I have covered some key aspects of ballerina and I hope you got
some understanding about what is ballerina and how we can use it in
the application development as well as the various deployment aspects.
So I'm going to do some quick demo around this so that you will get some
understanding about how ballerina application looks like and how we can
use it during the development time.
As well as how we can use various deployment capabilities built
in the banana distribution.
For this demo, I'm using a very simple service related
to hotel management service.
You can see the highlight hotel backend service, which is accepting
some incoming reservation request from the hotel web portal.
And it is contacting the room service to see the availability of the rooms.
And after that it is written.
Returning the confirmed reservations after doing some calculations and
few other transformations in between.
So it's a very simple service, but this will help us to understand how well
now application development looks like.
This is the already developed hotel management application
that I have described.
So I'm using the VS Code editor with the Balena plugin installed already.
You can see I have installed the Balena plugin, which comes with all the
visual features that I have explained.
So once you open your application, you can see multiple files here.
And these BAL files are where your application programming code is.
Is at.
So once you open those source files, you can see the source code lines
And also this is the balanatuml file that I explained which contains
some metadata about the package and so on So if you look at the main.
bin file, which contains the source code of the application Let me go through
some of the abstractions I explained in my slides So this is the service
abstraction, which is very easy to You define a service in Valerina because it
is a syntax, Valerina support service as a first class thing in, language syntax.
And when you attach a service with HTTP listener, it will become an HTTP service.
And if you attach it with a GraphQL listener, it will
become a GraphQL service.
You don't need to deal with underlying complexities.
You can provide additional configuration parameters to configure your listener.
But other than that, you don't have to worry about the underneath complexities.
And also that every service can have resource functions.
And if you look at these resource function signatures, those are very intuitive
because those looks like normal function calls where we have a function name,
input parameters, return types, and so on.
And after you design the skeleton of this application, how the services,
what are the services, What are the resources within each services?
It is just a matter of, implementing the business logic carefully.
So all these things comes with the visual, representation as well.
So if you open up the visual, panel of the ballerina application, you can
see the summary of your application.
It has, one function, one service.
Many records, many global variables and so on.
So these are the records that I mentioned, which is a canonical
format for representing your data.
And when it comes to the service, you can go to the service designer.
So this is the service designer.
You can see how many resources are there.
What are their types?
HTTP, POST, GET, DELETE and so on.
And you can edit these resources graphically.
And also you can, use the.
this is some summary.
And if you look at one of these functions, for example, bookings, you can see the
associated sequence diagram as well.
Let me.
Reduce the size a little bit.
So you can see the full logic and it is not that interesting because it is
interacting with only one other endpoint.
But if your resource function is talking to many different endpoints,
data services, databases, and gathering data, you can see all these things.
As a nice sequence diagram where you can understand the code easily.
So these are some, interesting things about Valerina.
And let me expand the source code.
So this is already implemented, simple service which gets the reservation request
as set of payload, arrays in the payload.
And I'm just iterating it to check the room availability
with the external service.
And do some conversions in between using this transform function and then
return that transformed message So if we look at this transform function that
is also A bit interesting because that contains the data mapper because I need
to convert one type into another So along with some other additional calculations
and other things in between for example You can drag and drop these fields into
each other using the, visuals panel.
And you can see, I combined the first name and last name using the, expression
editor, and you can do any other calculation in between if you need.
So this is the Balena data mapper, and we have auto map feature as well, where
we can, use AI support to generate these mappings based on the names
of the fields and types and so on.
Now, let's see how we can run this application locally.
To do that, you can use balerun command line, balerun command.
It will compile the application and run it in your local machine.
You can see I have attached the port 9090, so it will start
the service in the port 9090.
So you can invoke the service.
By using the curl
port 9 to 90 and you can see in the service path is hotel and let's invoke
a resource like, rooms or bookings.
You can see we don't have any bookings at the, as of now.
And if we look at rooms, it is.
Let me prettify it.
You can see the room details response, which is adjacent.
So now the service is up and running in your local machine.
And also you can use the try it feature available in ballerina
itself, where we have a swagger like view to test the application.
You can use the try out command here and you can see no bookings
and you can get the rooms.
Thanks.
You can use a tryout, execute, you can see the same response here.
I hope that you got some understanding about how the Balena code looks like, and
we already compiled it and run it locally.
Now, as the next step, let's see how we can run the application in the cloud.
Before doing that, let me add one more resource, that is to check
the readiness of the application by adding a readiness function.
So to do that, I added another resource function.
as health readiness, which is just returning HTTP.
Okay.
Then we need to add this as a readiness probe.
so to do that, we need to open the cloud.
tuml.
Cloud.
tuml file is a configuration file where you can use to modify it to, use to
modify the generated cloud artifacts.
You can see we already have the container image details.
And in addition to that, let me add the readiness probe.
You can see the values and parameters are auto suggested.
So I'm using them and the path is readiness.
And in addition to that, I need to add the base path as the slash hotel.
Now it's all good.
Let's use the build command to build the application.
Compile it and then generate the cloud artifacts.
do that, I'm using the build command with the cloud option as Kubernetes.
it will compile the source and it will generate the cloud artifacts.
can see there's some error in the readiness probe path.
That means the compiler understands the resource file, the implementation
as well as the cloud toml details.
Let's see what's the difference.
Here we have the name as readiness and my function name, resource
function name is different.
So let me fix it and quickly do the belpair command again.
Now you can see the artifacts are generating.
And finally you can see the commands to execute.
Before that, let's explore what happened in our target directory.
You can see under docker.
Now we have the docker file generated with all the dependencies required to run this.
And also under kubernetes, you can see the yaml file with all the
details like service versions and other metadata, number of replicas,
the image name to be used with this and also the readiness probe details
with the initial delay of 30 seconds.
So now everything is ready.
We didn't write any ml file manually.
All these things were generated by the command itself.
And we can use the cloud.
toml to configure some these values if you need.
Now let's try to run this.
I'm using Rancho desktop in my local machine and before running
this, let's see the docker images.
You can see the hotel API.
With the tag of 1 0 0 is generated about a minute ago now the Docker file
is available and let's use this command
to deploy the Kubernetes artifacts and You can see the service created deployment
created and Then let's use this command to export Or access the service via node port
hotel's this log service is now exposed as a node port Now, let's see our
kubernetes services and deployments
can see the deployment is created Let's see the services And the
services are created and you can see it's mapped to the This port 30517.
Now instead of localhost 9090 port that I used earlier, which is not
working now, we can use that port
which is deployed in our Kubernetes cluster
to invoke this application.
Now you can see the same response.
So we have deployed the application in the cloud without writing any
ml file or without generating the docker files manually.
So this is basically the end of my demo.
And this will give, I hope this gave an understanding about how we
can write the application and use the existing or built in commands
to generate the required artifacts.
With this demo, I hope you got a very good understanding about how Balerna looks
like and how we can use the various built in commands to handle the deployments.
I would like to wrap up my session by introducing you into
the Balerna community as well.
We have a very vibrant community and active, so you can visit balerna.
io community page.
And get to know various efforts and community activities, including
tech talks, training, university programs, and almost all of these
are very much, freely available for various audience groups and feel free
to join with us in the community.
And these are some images from various conferences, activities, meet hubs
that we have done in the recent past.
And you can subscribe to our events.
and get, be active on those as well.
And also if you are interested about learning ballerina,
visit ballerina website.
We have learn examples, learn pages, and we have a youtube video training
where you can get more in depth or hands on experience about ballerina.
And also we have ballerina certification if you are interested in gaining
more knowledge about ballerina.
And If you are using Balena feel free to raise your questions or any
clarifications in Balena discord channel as well as tech core flow.
Our community is very active in those channels and you
will get responses rapidly.
And also if you're open source contributor, feel free to join with us in
the Balena language hub repository and all our repositories are open source and you
can be part of the contributors as well.
So with that, I'm wrapping up my session.
Thank you very much for joining with this session and hope you have enjoyed.
Thank you.