What comes to your mind when we say a 3-tier project?
When you mention a "3-tier project," a specific software architecture pattern is used in application development. In this architecture, the application is divided into three distinct layers or tiers, each with its responsibilities:
Presentation Tier (Front-end): This is the top layer that interacts directly with the end-user. It's responsible for presenting the user interface (UI), receiving user input, and displaying information. In web applications, this tier is often implemented using technologies like HTML, CSS, and JavaScript.
Application Tier (Middle-tier or Backend): It handles tasks such as data processing, authentication, and interaction with the data tier. In a 3-tier architecture, this tier is typically implemented using server-side programming languages (e.g., Python, Java, Ruby) and may include web servers, application servers, and APIs. We are using NodeJS.
Data Tier (Backend or Database): It includes databases or data storage systems where information is stored and retrieved. Depending on the project's needs, this tier can involve relational databases like MySQL or PostgreSQL, NoSQL databases like MongoDB or Cassandra, or a combination of both. In our case, we are using MongoDB.
In a 3-tier architecture, each tier has its own distinct set of responsibilities, allowing developers to work on specific parts of the application independently. The Architecture diagram of a 3-tier project looks as follows:
Additionally, this architecture supports scalability and flexibility, making it suitable for a wide range of software projects, from small web applications to large enterprise systems.
Let's jump to practical implementation. The basic requirement would be we should have installed below mentioned tools.
Ubuntu OS ( Preferred )
Docker
Kubectl: In this section, we have installed Minikube.
Prometheus and Grafana
Note: Kindly check below mentioned GitHub link for step-wise installation of the above tools.
Installation Guide & Compose files:
https://github.com/sandeep15rana/installation.git
For this project refer "3-tier-project" folder
Now we will execute k8s compose files in sequence as follows. You can find these k8s compose files in the below link
Sequence:
DB ( mongo-config.yaml/mongo-secret.yaml/pv.yaml/mongo-pvc.yaml )
Frontend and Backend ( web-app.yaml )
The output of each k8s compose file as shown below:
mongo-config.yaml
mongo-secret.yaml
pv.yaml
mongo-pvc.yaml
To access the application from the browser
To get the application we need to understand the service object which we have created.
*'*Kind: Service' in kubernetes ( k8s ) enables network access to a sets of pods
*'*name: webapp-service' This is the name we have given to the service. This name can be used to reference the services in another part of k8s
'type: NodePort' This is the type of the Service. A NodePort Service makes the Service accessible on a specific port of each node in the cluster. In this case, it's exposed on the NodePort 30100.
'ports' This specifies the ports that the Service should listen on.
'protocol: TCP' This indicates that the service should use the TCP protocol
'port: 3000' This is the port on which the Service will listen within the cluster
'targetPort: 3000' This is the port to which traffic will be forwarded inside the Pods that match the label selector
'nodePort: 30100' This is a port on which traffic will be exposed on each node in the cluster. We can access the Service from outside the cluster using node's IP Address and this port. In my case node IP 192.168.49.2 and port is 30100.
Using Node IP address and port we can access the Application as shown below.
We can verify if everything is working as expected by checking the logs while creating the profile.
Prometheus and Grafana are popular open-source monitoring and visualization tools often used together to provide comprehensive monitoring and observability solutions for applications and infrastructure. After setting up its interface look like we can customize based on our requirement.
Thank you for reading :)
Let me know your feedback.