This project demonstrates the deployment of an Angular frontend application and a Spring Boot backend application using Kubernetes. It includes the necessary YAML files for deployment and service configuration. Follow the instructions below to deploy and configure the applications.
- Project Overview
- Prerequisites
- Deployment Instructions
- Service Configuration
- Post-Deployment Configuration
- Increasing Replicas
This project involves deploying an Angular frontend application and a Spring Boot backend application in a Kubernetes cluster. The deployment files and service configurations are provided to ensure a smooth setup and running of the applications.
- Kubernetes cluster
- kubectl configured and connected to your cluster
- Docker images for frontend and backend applications
- Source code of the project
-
Deploy the Backend Application
Apply the backend deployment and service YAML files:
kubectl apply -f backend-deployment.yaml kubectl apply -f backend-service.yaml
-
Deploy Frontend Application
Apply the frontend deployment and service YAML files:
kubectl apply -f frontend-deployment.yaml kubectl apply -f frontend-service.yaml
After deploying the applications, there are a few post-deployment configurations to perform:
The frontend application needs to communicate with the backend application. Therefore, you need to update the backend service endpoint in the frontend to the Node's public IP address. Follow these steps:
-
Identify the Node's Public IP Address
You can obtain the public IP address of your Kubernetes cluster's Node by running the following command:
kubectl get nodes -o wide
To ensure proper communication between the frontend and backend, follow these steps:
-
Modify
worker.service.tsin the frontend directory of your project. -
Replace the
backend-servicewith your Node Public IP address. -
Copy the file to the frontend application directory in the Kubernetes pod:
kubectl cp worker.service.ts <frontend-pod-name>:/opt/angular-frontend/src/app/services/worker.service.ts
-
Replace with the name of your frontend pod.
-
Modify
application.propertiesin the backend directory of your project. -
Replace the
database-endpoint, username and passwordwith your own data. -
Copy the file to the backend application directory in the Kubernetes pod:
kubectl cp application.properties <backend-pod-name>:/opt/spring-backend/src/main/resources/application.properties
-
Replace with the name of your backend pod.
-
Replace
<database-host>,<port>,<database-name>,<database-username>, and<database-password>with your database configuration.spring.datasource.url=jdbc:mysql://<database-host>:<port>/<database-name> spring.datasource.username=<database-username> spring.datasource.password=<database-password>
To scale the application based on your requirements, you can adjust the number of replicas for the frontend and backend deployments.
To scale the frontend application, follow these steps:
-
Determine the Current Number of Replicas
You can check the current number of replicas for the frontend deployment by running the following command:
kubectl get deployment frontend-app
-
To Scale the deployments just open the yaml file and enter the desired number of replicas and apply the files.