Skip to content
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

[master]Add Ballerina Deployment Guide #9660

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

lnash94
Copy link
Member

@lnash94 lnash94 commented Jan 3, 2025

Purpose

Describe the problems, issues, or needs driving this feature/fix and include links to related issues in the following format: Resolves issue1, issue2, etc.

Fixes ##9059

Address all the review suggestion in here : #9621

Checklist

  • Page addition

    • Add permalink to pages.
  • Page removal

    • Remove entry from corresponding left nav YAML file.
    • Add redirect_from on the alternative page.
    • If no alternative page, add redirection on the redirections.js file.
  • Page rename

    • Add front-matter redirect_from.
    • Add front-matter redirect_to: (if applicable).
  • Page restrcuture

    • Add permalink to pages.
    • Add front-matter redirect_from.
    • Add front-matter redirect_to: (if applicable).

@sm1990 sm1990 requested a review from shafreenAnfar January 17, 2025 04:21
@shafreenAnfar
Copy link
Contributor

  1. In the VM deployment, I think we need the CD part.
  2. When showing the GraalVM option I think we can mention, it is a replacement to the usually build step.

Talked about this with @lnash94

@lnash94
Copy link
Member Author

lnash94 commented Jan 24, 2025

Please note that the VM CD task will be added after completing the flow testing. Therefore, we will resume this work once the MI release is completed. :)


Use the `bal build` command to build the Ballerina package. This will generate Kubernetes YAML files and Docker container artifacts.

>**Note:** For macOS users with Apple Silicon chips, it is necessary to set the environment variable DOCKER_DEFAULT_PLATFORM to linux/amd64 before building the image. This requirement exists because the Ballerina Docker image does not currently support Apple Silicon chips.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
>**Note:** For macOS users with Apple Silicon chips, it is necessary to set the environment variable DOCKER_DEFAULT_PLATFORM to linux/amd64 before building the image. This requirement exists because the Ballerina Docker image does not currently support Apple Silicon chips.
>**Note:** For macOS users with Apple Silicon chips, it is necessary to set the environment variable `DOCKER_DEFAULT_PLATFORM` to `linux/amd64` before building the image. This requirement exists because the Ballerina Docker image does not currently support Apple Silicon chips.

- **Step 06:** Deploy the application to a Kubernetes cluster by applying the Kubernetes YAML configuration files generated by the Ballerina build in Step 2.
>**Note:** Replace <path to generated artifacts> with the actual path to the Kubernetes YAML files generated by the Ballerina build command (e.g., target/kubernetes).

See [Code to Cloud deployment](https://ballerina.io/learn/code-to-cloud-deployment/) for more information on deployment options in Kubernetes and Docker.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we going to have https://ballerina.io/learn/code-to-cloud-deployment/ pages as well after these changes?


For more reference,
- See [AWS Lambda](https://ballerina.io/learn/aws-lambda/) for more information.
- See [Azure Functions](https://ballerina.io/learn/azure-functions/) for information about deployment options that can be used in Azure Functions.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we going to have above two pages in the learn section after these changes? If so what is the landing page location? And how do we handle the information loss (i.e. I see more information on those pages like supported triggers etc)

3. Install any other dependencies your Ballerina service might need (e.g., database drivers, libraries).

4. Write Ballerina code.
**service.bal**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image Check the above

- Ensure the server meets the hardware requirements for your application (CPU, memory, disk space, etc.).
- Configure the server OS (Linux is recommended for production).

2. Install the Ballerina distribution from [the Ballerina Installation options.](https://ballerina.io/downloads/)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
2. Install the Ballerina distribution from [the Ballerina Installation options.](https://ballerina.io/downloads/)
2. Install [Ballerina](https://ballerina.io/downloads/).

> **Tip:** you can access your service locally via `kubectl port-forward`
`$ kubectl port-forward svc/hello-k8s-svc 8081:8080`

Test the service using curl
Copy link
Contributor

@anupama-pathirage anupama-pathirage Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Test the service using curl
Test the service using cURL.


1. Create a new Ballerina package.

$ bal new hello_k8s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing ``` for code segment?

hello-k8s-svc-local NodePort 10.99.245.41 <none> 9090:30342/TCP,9091:30515/TCP 66s
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 130m
```
- Execute the curl http://192.168.49.2:30342/helloWorld/greeting command to access the deployed service via cURL.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Execute the curl http://192.168.49.2:30342/helloWorld/greeting command to access the deployed service via cURL.
- Execute the following command to access the deployed service via cURL.

@@ -0,0 +1,354 @@
---
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sm1990 Sometimes I am getting the following error when trying to render this page locally. Any idea?

image

kubectl apply -f <path to generated artifacts>
```
The push event can initiate a workflow to the deployment process to the Kubernetes cluster.
- **Step 02:** This step builds the Ballerina project, compiling the source code and preparing the necessary artifacts for deployment in Kubernetes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the step 1?

}
```

3. Use `bal build` for generating the AWS Lambda artifacts.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
3. Use `bal build` for generating the AWS Lambda artifacts.
3. Use `bal build` to generate the AWS Lambda artifacts.

$ bal build --cloud="aws_lambda"
```

4. Execute the AWS CLI command to deploy the function, here it creates and publishes the functions by replacing the respective AWS, $LAMBDA_ROLE_ARN, $REGION_ID, and $FUNCTION_NAME values given in the command with your values.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider rewriting the sentence to avoid , here


This example demonstrates how to write a simple echo function in Azure Functions using Ballerina, where triggers
are represented by listeners attaching an `af:HttpListener` to a service that implies an HTTP trigger.
The resource method behaves like a `ballerina/http` service, In the provided code sample, there's an empty service path and a resource path
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we starting a new sentence from In the?


1. Set up the prerequisites by following [these instructions.](https://ballerina.io/learn/azure-functions/#set-up-the-prerequisites)

2. Here is an example Ballerina code.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
2. Here is an example Ballerina code.
2. Here is an sample Ballerina code.

@anupama-pathirage
Copy link
Contributor

@lnash94 Can you please schedule a meeting to discuss the above points? Specially the current code to cloud page positioning etc.

| Ballerina Swan Lake version | Compatible Java version |
|-----------------------------------------------------------------------------------------|-------------------------|
| Ballerina Swan Lake (2201.0.0) up to Ballerina Swan Lake Update 7 (2201.7.0) | JDK Temurin 11 |
| Ballerina Swan Lake Update 8 (2201.8.0) up to Ballerina Swan Lake Update 10 (2201.10.0) | JDK Temurin 17.0.7 |
Copy link
Member

@anuruddhal anuruddhal Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we remove the specific versions JDK Temurin 17.0.7 -> JDK Temurin 17.x ?

> **Tip:** You can build the GraalVM executable in Kubernetes.
>
> GraalVM enhances Kubernetes deployments of Ballerina applications by enabling faster startup times and reduced memory usage. These advantages make it ideal for microservices workloads that demand rapid scaling and minimal resource consumption in a containerized environment. GraalVM’s native image feature uses ahead-of-time compilation, producing lightweight containers and improving Kubernetes deployment efficiency. The GraalVM build is best suited for deployments that prioritize fast scaling and reduced resource usage, while the standard JVM build is more appropriate for services that do not require such optimizations.
> Execute the command below to build a Ballerina package.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a line saying the build time will be higher for Graal VM builds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants