Kubernetes is an operating system for containerized applications. It provides guaranteed processing capacity and automatic resume from system failures. Almost all modern microservices can benefit from Kubernetes.
For the demo purpose, we create a small Kubernetes cluster. It is straightforward in Calabash. Just fill out a self-explanatory design form. The following screenshot is the top portion of the design form for the cluster.
Calabash (tester:lake_finance)> deploy i lf-cluster Cluster created, checking for K8s service endpoint... Checking status of k8s api service... retries remain: 30 Deployed to 34.82.151.214 Calabash (tester:lake_finance)>The IP address of the control plane endpoint is returned. We can use it to deploy applications to the cluster. Next, we update the microservice “app-demo” to use this Kubernetes cluster.
In this form, we changed “Infrastructure object type” from “Microservice on VM” to “Microservice on Kubernetes.” Then we selected the Kubernetes cluster to use. We also created a namespace for our application. The namespace is optional but highly recommended.
That is all we need to do. Now our app is ready to be deployed to the Kubernetes cluster.
Once the deployment is successful, you can continue to modify the design and redeploy it. There will be no interruption to the app from the redeployment. A rolling update will be performed, which shuts down old nodes only when new nodes have been successfully created. This way, your app will provide continuous service.
The following is a transcript of the deployment using Calabash CLI.
Calabash CLI, version 3.0.0 Data Canals, 2022. All rights reserved. Calabash > connect tester Password: Connected. Calabash (tester)> use ds lake_finance Current ds set to lake_finance Calabash (tester:lake_finance)> deploy i app-demo Deploy to cloud? [y]: Deploying new ms on k8s ... Deploying microservice app-demo in namespace app-demo ... Namespace created: app-demo Creating service ... Creating new service app-demo Service created: app-demo Checking service status ... retries left: 19 Checking service status ... retries left: 18 Creating metadata lake_finance__app-demo__svcip = 35.197.28.152 Waiting #0 for image build... Waiting #0 for image build... Latest build: 3da04ccd-fbab-4ec1-afac-1bc7eb07c180, Started: 2021-12-31T07:22:10.261780951Z, Current status: SUCCESS Got a successful latest build: 3da04ccd-fbab-4ec1-afac-1bc7eb07c180 Creating new secret app-demo-secret Secret created: app-demo-secret Deployment created: app-demo HPA created: app-demo Deployed to 34.127.0.27:8888 (external) Calabash (tester:lake_finance)>
The deployment process creates Kubernetes namespace, service, secrets, deployment, and horizontal pod autoscaling (HPA). As before, it also builds our application docker image. When all is fine, the service URL is displayed. Here “(external)” means this service is open to the internet.
We can access our application from our PC outside the cloud:
% curl http://34.127.0.27:8888 Hello world!
The Cost
In this tutorial topic, the cost is mainly from the two nodes in the Kubernetes cluster. Each is at about $26/month if run 24×7.
But you can undeploy the cluster when you are done with the practice. It will cost significantly less.