Deploying Microservice App on K8s

Part 1: Project Introduction and App Architecture

ยท

5 min read

Deploying Microservice App on K8s

This project is about a big project that will comprise small projects that make a big project as a whole, and because of this you will get both a zoomed-out overview and detailed knowledge of each aspect of deployment on Kubernetes on the cloud. Because we will do a lot of stuff, this big project will be covered in a blog series of which this blog is the first part. This project aims to simulate a real-world deployment of a microservice-based app on Kubernetes.

What are we going to do?

We will deploy a web application based on microservices architecture on Kubernetes using AWS Cloud's EKS service with a database in AWS RDS service. We are not just going to deploy the web app but also build the whole AWS architecture for it using Terraform along with this we are going to build a CI/CD pipeline for it with a GitOps approach.

We are also going to explore a lot of configuration aspects in all the stages of the deployment be it networking configurations within the K8s cluster or between the K8s cluster and other services in AWS architecture, be it Kubernetes manifests configurations which include cluster autoscaling, deployment, statefulset, services, configmaps, k8s secret configurations, dynamic storage allocation in the K8s cluster (we are going to have persistent storage in our K8s cluster) and much more.

Well, the above description is to give you a taste of the project and it does not include all the stuff that we are going to do because there is so much stuff that the blog will get so long if I started mentioning each of them here, so further in this blog series, the blog may contain some stuff that I did not mention above. We will know each thing as we do it.

What are the Prerequisites?

It is good to know the basics of these-

  • Docker, Check out this blog, to learn about docker-

  • Kubernetes, Check out this blog, to learn about Kubernetes-

  • You should be willing to spend some money on the AWS cloud as this project will cost you some money even if you are in the AWS free tier though the amount is not that big.

There are other pre-requisites too but I suggest you to learn about them as you build the project.


The Application to Deploy

We will deploy a microservice architecture web application. The web application itself is simple and does not do anything impressive, but it has all the architecture components that will simulate a relatively sophisticated deployment. The web application is a "Tasklist" wherein users can store, edit, and delete tasks.

Application Architecture

The web application has 2 microservices, Backend and Authentication.

Backend

  • The backend contains HTML for webpages and it has the logic of the application.

  • The backend uses a comma-separated value (CSV) file to store the user's tasks. Although there are better ways to store user tasks than storing them in a CSV file but since I want to demonstrate the data persistence on K8s, storing tasks in a CSV will require the setup of data persistence on the K8s cluster hence I will be able to show you data persistence.

  • The backend creates a separate CSV file for every user.

  • The user interacts only with the backend.

Authentication

  • Authentication microservice authenticates user login credentials (username and password)

  • Authentication also verifies JWT (JASON Web Tokens) which are included in every request from the user.

  • Authentication also registers the user with the database when the user signs up.

Communication between microservices

The user only interacts with the backend, whenever the user logs in with credentials, the backend microservice gets the user credentials and then forwards the same credentials to the authentication microservice. The authentication microservice looks for the credentials in the database and verifies it, authentication then forwards the response to the backend microservice. Authentication returns a 201 status code if the credentials are correct otherwise, it returns a 404 status code. The backend then logs in the user if the credentials are correct otherwise it shows invalid credentials.

Authentication also verifies the JWT (JASON Web Tokens) included in the user's request header. At every user request the backend microservice receives, the backend forwards the JWT received in that request to the authentication microservice. The authentication microservice then verifies the JWT and forwards the response back to the backend with a 200 status code if the JWT is correct. The backend then responds to the user request if the JWT is correct otherwise backend forwards the user to the login page.

Authentication registers the user with the username, password, name, and email of the user that gets forwarded to it by the backend when a user fills the signup page and clicks on signup. The backend shows signup successful to the user if it receives status code 200 from the authentication otherwise it shows invalid signup. Invalid signup occurs when users sign up with an already registered username or email.

So you see the pattern here? Backend microservice uses authentication microservice for every authentication task and responds to the user according to the response it gets from authentication.


That is it for this part of the series, the next part will be on the cloud architecture and terraform code to build that architecture for the app. If you have any questions please feel free to ask in the comments section

If you have any questions about what I have discussed, feel free to ask in the comments section.

Share the blog socials and tag me on X and LinkedIn for the #buildinpublic initiative.

Follow me on X and LinkedIn

Thank You for Reading๐Ÿ˜

ย