ballerina/cloud2.0.0-beta.2
Overview
This modules provides the capabilities to generate the cloud artifacts for Ballerina programs.
This module generates the Kubernetes and Docker artifacts required to deploy a Ballerina program in the cloud.
Supports following artifact generation:
- Kubernetes deployment
- Kubernetes service
- Kubernetes liveness probe
- Kubernetes readiness probe
- Kubernetes config map
- Kubernetes horizontal pod autoscaler
- Docker image
- Dockerfile
Docker artifact generation
Build the Ballerina Program with --cloud=docker
option to generate Docker artifacts (Dockerfile and Docker image).
1$> bal build --cloud=docker2Compiling source3 hello/hello:0.0.145Creating balas6 target/bala/hello-2020r2-any-0.0.1.bala78Running Tests910 hello/hello:0.0.111 No tests found121314Generating executables15 target/bin/hello.jar1617Generating artifacts...1819 @kubernetes:Docker - complete 2/22021 Execute the below command to run the generated docker image:22 docker run -d -p 9090:9090 anuruddhal/hello-api:sample82324 target/bin/hello-0.0.1.jar
Kubernetes artifact generation
Build the Ballerina Program with --cloud=k8s
option to generate Docker and Kubernetes artifacts.
1$> bal build --cloud=k8s2Compiling source3 hello/hello:0.0.145Creating balas6 target/bala/hello-2020r2-any-0.0.1.bala78Running Tests910 hello/hello:0.0.111 No tests found121314Generating executables15 target/bin/hello.jar1617Generating artifacts...1819 @kubernetes:Service - complete 1/120 @kubernetes:Deployment - complete 1/121 @kubernetes:HPA - complete 1/122 @kubernetes:Docker - complete 2/22324 Execute the below command to deploy the Kubernetes artifacts:25 kubectl apply -f /Users/anuruddha/workspace/ballerinax/module-ballerina-c2c/samples/sample2/target/kubernetes/hello2627 Execute the below command to access service via NodePort:28 kubectl expose deployment hello-hello-0-0-deployment --type=NodePort --name=hello-hello-0-0-svc-local
Cloud.toml
The configuration file to be used to override the default values generated by code to cloud.
The Cloud.toml
file is completely optional and only has to specify the values that need to be overridden.
If the value is not specified for a certain field, the compiler will take the default value.
All the supported properties can be found here.
Records
[2]
ScheduleConfig | Cron Job Schedule Configuration. |
TaskConfig | Task Configuration. |
Annotations
[2]
Expose | @cloud:Expose annotation marks a port that has to be exposed in a custom listener initializer. |
Task | @cloud:Task annotation to configure cron job. |