Kaushal's Photo
Home Follow on LinkedIn Share on LinkedIn Share on Twitter

To design the best pod model for a web application stack consisting of Angular (Frontend), Spring Boot Microservices (Backend), and MS SQL Server (Database), you should consider scalability, resilience, and separation of concerns. Below is an ideal pod model and deployment setup:


1. Pod Design Principles

  • Separation of Concerns: Each component (frontend, backend, and database) should run in its own set of pods to ensure independent scaling and management.
  • Stateless Frontend and Backend: Frontend (Angular) and backend (Spring Boot) should be stateless for scalability and fault tolerance. Store session data in a shared, external cache (e.g., Redis).
  • Persistent Storage for Database: MS SQL Server pods require persistent volumes to ensure data durability.

Component Pod Design Notes
Frontend (Angular) 1 Deployment, multiple pods - Stateless.
- Served via NGINX/Apache for optimal static file delivery.
Backend (Spring Boot) 1 Deployment per service, multiple pods - Stateless.
- Each microservice runs in its own pod for modularity.
Database (MS SQL) 1 StatefulSet, single pod - Use StatefulSet for database pods to manage persistence.
- Attach Persistent Volume (PV).

3. Kubernetes Resources for Each Component

a. Frontend (Angular)

  • Use a Deployment to run the Angular app as a static web application served by NGINX or Apache.
  • Expose the Angular app using a Service with a LoadBalancer or Ingress for public access.

Deployment Example:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: angular-frontend
spec:
  replicas: 3
  selector:
    matchLabels:
      app: angular-frontend
  template:
    metadata:
      labels:
        app: angular-frontend
    spec:
      containers:
      - name: angular
        image: nginx:latest
        ports:
        - containerPort: 80
        volumeMounts:
        - name: angular-code
          mountPath: /usr/share/nginx/html
      volumes:
      - name: angular-code
        configMap:
          name: angular-config
---
apiVersion: v1
kind: Service
metadata:
  name: angular-service
spec:
  type: LoadBalancer
  selector:
    app: angular-frontend
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80

b. Backend (Spring Boot Microservices)

  • Create a Deployment for each microservice.
  • Use an Internal Service (ClusterIP) for communication between microservices.
  • Expose APIs externally via an Ingress or LoadBalancer for public endpoints.

Deployment Example:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: springboot-service
spec:
  replicas: 3
  selector:
    matchLabels:
      app: springboot-service
  template:
    metadata:
      labels:
        app: springboot-service
    spec:
      containers:
      - name: springboot
        image: myregistry/springboot:latest
        ports:
        - containerPort: 8080
        env:
        - name: DB_HOST
          value: "mssql-service"
---
apiVersion: v1
kind: Service
metadata:
  name: springboot-service
spec:
  type: ClusterIP
  selector:
    app: springboot-service
  ports:
  - protocol: TCP
    port: 8080
    targetPort: 8080

c. Database (MS SQL Server)

  • Use a StatefulSet to deploy the database with a Persistent Volume for durable storage.
  • Attach a PersistentVolumeClaim (PVC) to store database data.
  • Expose the database internally via a ClusterIP service.

StatefulSet Example:

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mssql
spec:
  serviceName: "mssql-service"
  replicas: 1
  selector:
    matchLabels:
      app: mssql
  template:
    metadata:
      labels:
        app: mssql
    spec:
      containers:
      - name: mssql
        image: mcr.microsoft.com/mssql/server:2019-latest
        ports:
        - containerPort: 1433
        env:
        - name: ACCEPT_EULA
          value: "Y"
        - name: SA_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mssql-secret
              key: sa-password
        volumeMounts:
        - name: mssql-data
          mountPath: /var/opt/mssql
  volumeClaimTemplates:
  - metadata:
      name: mssql-data
    spec:
      accessModes: ["ReadWriteOnce"]
      resources:
        requests:
          storage: 20Gi
---
apiVersion: v1
kind: Service
metadata:
  name: mssql-service
spec:
  type: ClusterIP
  selector:
    app: mssql
  ports:
  - protocol: TCP
    port: 1433
    targetPort: 1433

4. Traffic Flow

  1. User Access:
    Users access the Angular frontend via a LoadBalancer or Ingress.
    Example: https://frontend.example.com.

  2. Frontend to Backend:
    The Angular frontend calls Spring Boot APIs via the internal DNS name of the service.
    Example: http://springboot-service.default.svc.cluster.local.

  3. Backend to Database:
    The Spring Boot microservice connects to the MS SQL database via the ClusterIP service.
    Example: mssql-service:1433.


5. Scalability Recommendations

  • Frontend: Scale horizontally by increasing replicas in the deployment based on user load.
  • Backend: Scale microservices independently as needed, based on API demand.
  • Database: Use vertical scaling (increase CPU/RAM) or deploy a replica set for read scalability.

6. Security Best Practices

  • Use Secrets for sensitive information like database passwords.
  • Implement Network Policies to restrict communication between pods.
  • Use TLS for secure communication between frontend, backend, and external clients.

This pod model ensures modularity, scalability, and high availability for your Angular-Spring Boot-MS SQL stack.

© 2025 Kaushal Kishor. All rights reserved.

Follow on LinkedIn