V 0.991
Ballerina is an open source programming language and platform for cloud-era application programmers to easily write software that just works.
When deploy the services on the cluster, verify that the following calls work:
- should succeed only inside the cluster
curl GET http://wiarriors-service/api/v1/warriors- Outside the cluster with a valid apikey should succeed
curl GET http://techwatch.io/api/v1/apigw/warriors -H "apikey: Z2FtZTpnYW1lMQ==" - Outside the cluster with a invalid apikey should fail
curl GET http://techwatch.io/api/apigw/v1/warriors -H "apikey: G02TheBeach==" # use ballerina init command inside the work directory
ballerina init-
Code the config and logic the service
Add the API Gateway service as a ballerina module, create the service class and code the config and logic of the API Gateway
The Kubernetes config of the internal service (do the same for warriors service)
@kubernetes:Service {
name: "Warriors"
}
@kubernetes:Deployment {
image: "warriors", // remember the docker image should contain only simple letters
name: "WarriorsService",
replicas: 3,
namespace: "wired-services",
buildImage: false,
labels: {team:"WIRED", scope:"SERVICE"},
dockerHost: "tcp://192.168.99.103:2376", // IP can be obtained via `minikube ip` command
dockerCertPath: "~/.minikube/certs", // Docker cert path should be configure here
singleYAML: true
}To build the docker image, add docker expose config, will build the docker image when run the ballerina build command
@docker:Expose{}We need a Kubernetes cluster running, in this example we use minikube, install it and start the cluster:
minikube startAnd then build the project using command ballerina build <module>,
will build the specified module or all modules if no specifications.
ballerina build warriorsThe deployment commands are logged when run ballerina build.
- Docker container
docker run -d -p 9090:9090 warriors:latest- Kubernetes deployment
kubectl apply -f <path-to-your-projec-dir>/target/kubernetes/warriorsThe current version of the intellij plugin has bugs, the vsc plugin will be used to continue this work.










