Event-based integration is a key pattern for implementing microservices. In this chapter, you will learn how to how to implement microservices on AKS, including how to use Event Hub for loosely coupled integration between the applications. The securing of the communications between microservices will also be introduced to the reader. Microservices, when implemented with the correct organization/support in place, help businesses develop a growth mindset in their teams. DevOps maturity is crucial in making the digital transformation of companies a reality. You, as a developer and/or an engineer responsible for site reliability, will learn how to deploy them, and also how to leverage Azure Event Hub to store events. As you will learn in this chapter, events-based integration is one of the key differentiators between monolithic and microservice...
You're reading from Hands-On Kubernetes on Azure
Technical requirements
You will need to use a modern browser, such as Firefox, Chrome, or Edge.
Introducing to microservices
Microservices are an architectural pattern for organizing your application according to business domains. For more information on microservices, please see https://martinfowler.com/articles/microservices.html. Classic examples that are usually provided for microservices are how customer, movies, and recommendation services are implemented. Customer service simply deals with customer details, and has no information about movies. The movies service deals with movie details and nothing more. The recommendation engine service deals with recommendations only, and, given a movie title, will return the movie that are closely related.
One of the main selling points of microservices is strengthen independence. Services are designed to be small enough (hence the name micro) to handle the needs of a business domain. As they are small, they can be made self-contained...
Deploying a set of microservices
We will be deploying a set of microservices called a social network. The service is composed of two main service, users and friends. The users service stores all the users in its own data store. The friends service stores the user's friends. The events of adding a user/adding a friend are sent to a recommendation service backed by a graph database that is then used to query relationships between users. You can query the graph database with questions, such as give me the common friends of user X and user Y.
In the following section, you will do the following:
- Use Helm to deploy a sample microservice-based application
- Test the service by sending events and watch objects being created and updated
Deploying Helm
Using Azure Event Hubs
Running Kafka locally is OK for demo purposes, but not suitable for production use. The same reasons why you wouldn't want to run your own database server are why you would avoid running and maintaining your own Kafka instance. Azure Event Hub has added support for the Kafka protocol, so with minor modifications, we can update our application from using local Kafka instance to the scalable Azure Event Hub instance.
In the following sections, we will do the following:
- Create the Azure Event Hub via the portal and gather the required details to connect our microservice-based application.
- Modify the Helm chart to use the newly created Azure Event Hub.
Creating the Azure Event Hub
Perform the following...
Summary
We started this chapter by covering microservices, their benefits and their trade-offs. Following this, we went on to deploy a set of microservices called social network, where we used Helm to deploy a sample microservice-based application. We were able to test the service by sending events and watching objects being created and updated. Finally, we covered the storing of events in Azure Event Hub using Kafka support, and we were able to gather the required details to connect our microservice-based application and modify the Helm chart. The next chapter will cover cluster and port security using secret objects provided by Kubernetes.