Code2cloud extension implementation for ballerina.
- Kubernetes deployment support.
- Kubernetes service support.
- Kubernetes liveness probe support
- Kubernetes readiness probe support
- Kubernetes horizontal pod autoscaler support.
- Docker image generation.
- Dockerfile generation.
- Kubernetes config map support.
Refer samples for more info.
The base image required for the module is published to Dockerhub
- Download and install JDK 21
- Export github personal access token & user name as environment variables.
export packagePAT=<Token> export packageUser=<username>
- (optional) Specify the Java home path for JDK 21 ie;
export JAVA_HOME=/Library/Java/JavaVirtualMachines/temurin-21.jdk/Contents/Home
- Install Docker
- Get a clone or download the source from this repository (https://github.com/ballerina-platform/module-ballerina-c2c)
- Run the Gradle command
gradle build
from within themodule-ballerina-c2c
directory. - Copy
c2c-extension/build/c2c-extension-***.jar
file to<BALLERINA_HOME>/bre/lib
directory. - Copy
c2c-ballerina/build/target/c2c-ballerina-zip/bala/ballerina/cloud
directory to<BALLERINA_HOME>/repo/bala/ballerina
directory. - Copy
c2c-ballerina/build/target/c2c-ballerina-zip/cache/ballerina/cloud
directory to<BALLERINA_HOME>/repo/cache/ballerina
directory.
- Use the "BAL_DOCKER_DEBUG=true" environment variable to enable docker related debug logs when building the ballerina source(s).
- Use the "BAL_KUBERNETES_DEBUG=true" environment variable to enable kubernetes related debug logs when building the ballerina source(s).
import ballerina/http;
import ballerina/log;
listener http:Listener helloEP = new(9090);
service /helloWorld on helloEP {
resource function get sayHello() returns string {
return "Hello, World from service helloWorld ! ";
}
}
Build the program with --cloud=k8s
or --cloud=docker
build option.
$ bal build --cloud=k8s <source_file>.bal
The Kubernetes and Docker artifacts will be created in following structure.
$> tree
├── docker
│ └── Dockerfile
|-kubernetes
└── hello-world.yaml