Microservices in Practice: Deployment Shouldn't Be an Afterthought

Microservices in Practice: Deployment Shouldn't Be an Afterthought

Follow this article to learn more about the set of cloud-native abstractors in Ballerina’s built-in Kubernetes support for Microservices your deployment. Microservice architecture is one of the most popular software architecture styles that enables the rapid, frequent, and reliable delivery of large, complex applications. There are numerous learning materials on the benefits of microservices, design, and implementations.

Microservice architecture is one of the most popular software architecture styles that enables the rapid, frequent, and reliable delivery of large, complex applications. There are numerous learning materials on the benefits of microservices, design, and implementations. However, there are very few resources that discuss how to write your code to cloud-native platforms like Kubernetes in a way that just works. In this article, I am going to use the same microservice E-Commerce sample used in the Rethinking Programming: Automated Observability article and discuss Ballerina’s built-in Kubernetes support to extend it to run in Kubernetes platforms.

The sample code covers the implementation of an e-commerce backend that simulates the microservices required to implement searching for goods, adding them to a shopping cart, doing payments, and shipping. 

E-Commerce Backend Microservices Architecture

E-Commerce Backend Microservices Architecture

Code to Kubernetes

Docker helps to package the application with its dependencies while Kubernetes helps to automate deployment and scaling and to manage containerized applications. Kubernetes defines a set of unique building blocks that collectively provide mechanisms to deploy, maintain, and scale applications. 

On the other hand, the developer has to write code in a certain way to work well in a given execution environment. The microservices have to be designed, architected, and implemented in a way that performs well in a platform like Kubernetes. Otherwise, the application code will not be well-fitting to the Kubernetes building blocks. In other words, deployment should not be an afterthought, we should design and write our code to run in Kubernetes.

Let’s look at potential Kubernetes deployment architecture for the above e-commerce application. 

Kubernetes Deployment Architecture for E-commerce Backend Microservices

Kubernetes Deployment Architecture for E-commerce Backend Microservices

One of the main challenges that developers are facing is the lack of tools and programing language abstraction support to design and implement the microservices to work well in Kubernetes. As a solution to this problem, Ballerina has introduced a set of cloud-native abstractions and tools to write microservices that just work in platforms like Kubernetes.

Let’s look at how we can use Ballerina’s Kubernetes abstraction to extend the e-commerce microservices to run in Kubernetes.

Order Management Microservice

The order management microservice named OrderMgt is the simplest microservices because it provides a set of functionality for billing, shipping, and admins but it is not dependant on any other microservices to complete the tasks. Let’s see how we can extend the OrderMgt microservice to support running in Kubernetes.

Java

1

@kubernetes:HPA {

2

   minReplicas: 1,

3

   maxReplicas: 4,

4

   cpuPercentage: 75,

5

   name: "ordermgt-hpa"

6

}

7

@kubernetes:Service {

8

   name: "ordermgt-svc"

9

}

10

@kubernetes:Deployment {

11

   name: "ordermgt",

12

   image: "index.docker.io/$env{DOCKER_USERNAME}/ecommerce-ordermgt:1.0",

13

   username: "$env{DOCKER_USERNAME}",

14

   password: "$env{DOCKER_PASSWORD}",

15

   push: true,

16

   livenessProbe: true,

17

   readinessProbe: true,

18

   prometheus: true

19

}

20

service OrderMgt on new http:Listener(8081) {

microservice architecture microservice kubernates ballerina programing language

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Microservices in Practice: Deployment Shouldn't Be an Afterthought

Follow this article to learn more about the set of cloud-native abstractors in Ballerina’s built-in Kubernetes support for Microservices your deployment.

Serverless Vs Microservices Architecture - A Deep Dive

Companies need to be thinking long-term before even starting a software development project. These needs are solved at the level of architecture: business owners want to assure agility, scalability, and performance.

Microservices in Practice: Deployment Shouldn't Be an Afterthought

Follow this article to learn more about the set of cloud-native abstractors in Ballerina’s built-in Kubernetes support for Microservices your deployment. Microservice architecture is one of the most popular software architecture styles that enables the rapid, frequent, and reliable delivery of large, complex applications. There are numerous learning materials on the benefits of microservices, design, and implementations.

The Service Mesh in the Microservices World - DZone Microservices

In this article, take a look at the service mesh in the microservices world. The software industry has come a long journey and throughout this journey, Software Architecture has evolved a lot. Starting with 1-tier (Single-node), 2-tier (Client/ Server), 3-tier, and Distributed are some of the Software Architectural patterns we saw in this journey.

Top 5 Programming Languages to Learn in 2021 | Top Programming Languages | Intellipaat

In this video, you will know the top 5 Programming languages to learn in 2021. It is always confusing for a beginner to choose a programming language from th...