Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
0977b7e
pushed
SwayamNac Apr 6, 2025
157c4f6
Update docker-compose.yml
Swayamnakshane Apr 7, 2025
df53f74
Update Dockerfile
Swayamnakshane Apr 7, 2025
3eb7751
Update bankapp-deployment.yml
Swayamnakshane Apr 12, 2025
43b6b2a
Delete kubernetes/bankapp-hpa.yml
Swayamnakshane Apr 12, 2025
a291f89
Delete kubernetes/bankapp-ingress.yml
Swayamnakshane Apr 12, 2025
6837bfe
Update bankapp-namespace.yaml
Swayamnakshane Apr 12, 2025
96ef1f2
Update bankapp-service.yaml
Swayamnakshane Apr 12, 2025
a71528a
Update configmap.yaml
Swayamnakshane Apr 12, 2025
e9d9390
Delete kubernetes/letsencrypt-clusterissuer.yaml
Swayamnakshane Apr 12, 2025
3ff137e
Update mysql-deployment.yml
Swayamnakshane Apr 12, 2025
1574abe
Update mysql-service.yaml
Swayamnakshane Apr 12, 2025
7f3a681
Update persistent-volume-claim.yaml
Swayamnakshane Apr 12, 2025
c540fd6
Update persistent-volume.yaml
Swayamnakshane Apr 12, 2025
b5e8149
Update secrets.yaml
Swayamnakshane Apr 12, 2025
e6c9727
Update configmap.yaml
Swayamnakshane Apr 12, 2025
6e8aee2
Update mysql-deployment.yml
Swayamnakshane Apr 12, 2025
86ad8bd
Update mysql-service.yaml
Swayamnakshane Apr 12, 2025
d0a31ff
Update mysql-deployment.yml
Swayamnakshane Apr 12, 2025
502420f
Update mysql-deployment.yml
Swayamnakshane Apr 12, 2025
02d37d5
Update mysql-deployment.yml
Swayamnakshane Apr 12, 2025
dfdfd18
Update mysql-deployment.yml
Swayamnakshane Apr 12, 2025
c56bbe9
Update mysql-deployment.yml
Swayamnakshane Apr 12, 2025
ddcb169
Update mysql-deployment.yml
Swayamnakshane Apr 12, 2025
15d0f21
Update secrets.yaml
Swayamnakshane Apr 12, 2025
37b6c4e
Update bankapp-deployment.yml
Swayamnakshane Apr 12, 2025
e0b3c45
Update persistent-volume.yaml
Swayamnakshane Apr 12, 2025
cb930ce
Update persistent-volume-claim.yaml
Swayamnakshane Apr 12, 2025
ccff992
Update mysql-deployment.yml
Swayamnakshane Apr 12, 2025
d0b6471
Update mysql-deployment.yml
Swayamnakshane Apr 12, 2025
64223fb
Update persistent-volume-claim.yaml
Swayamnakshane Apr 12, 2025
5f2c13e
Update persistent-volume-claim.yaml
Swayamnakshane Apr 12, 2025
7d724c0
Update persistent-volume.yaml
Swayamnakshane Apr 12, 2025
b02e0a8
Update mysql-deployment.yml
Swayamnakshane Apr 12, 2025
1bc0ed5
Update mysql-deployment.yml
Swayamnakshane Apr 12, 2025
f3357df
Update docker-compose.yml
Swayamnakshane Apr 18, 2025
1b5fc72
Update bankapp-deployment.yml
Swayamnakshane Apr 18, 2025
f241fe1
kube added
SwayamNac Apr 26, 2025
c0fcac6
add
SwayamNac Apr 26, 2025
8be0234
Update mysql-deployment.yml
Swayamnakshane Apr 26, 2025
37f9e69
Update mysql-deployment.yml
Swayamnakshane Apr 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 11 additions & 36 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,37 +1,12 @@
#----------------------------------
# Stage 1
#----------------------------------

# Import docker image with maven installed
FROM maven:3.8.3-openjdk-17 as builder

# Add maintainer, so that new user will understand who had written this Dockerfile
MAINTAINER Madhup Pandey<madhuppandey2908@gmail.com>

# Add labels to the image to filter out if we have multiple application running
LABEL app=bankapp

# Set working directory
WORKDIR /src

# Copy source code from local to container
COPY . /src

# Build application and skip test cases
#---------------------------------stage1-----------------------------------------
FROM maven:3.9.6-eclipse-temurin-17-alpine AS builder
WORKDIR /app
COPY . .
RUN mvn clean install -DskipTests=true

#--------------------------------------
# Stage 2
#--------------------------------------

# Import small size java image
FROM openjdk:17-alpine as deployer

# Copy build from stage 1 (builder)
COPY --from=builder /src/target/*.jar /src/target/bankapp.jar

# Expose application port
EXPOSE 8080

# Start the application
ENTRYPOINT ["java", "-jar", "/src/target/bankapp.jar"]

#---------------------------------stage2-----------------------------------------
FROM openjdk:17-slim
WORKDIR /app
COPY --from=builder /app/target/*.jar /app/target/bank.jar
EXPOSE 8081
CMD ["java","-jar","/app/target/bank.jar"]
35 changes: 13 additions & 22 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,34 @@ services:
image: mysql:latest

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Pin Docker image versions for stability.
Using mysql:latest and bankapp:latest may introduce breaking changes when upstream images update. Specify exact tags (e.g., mysql:8.0.33, bankapp:1.2.0) to ensure reproducible builds.

Also applies to: 18-18

container_name: mysql
environment:
- MYSQL_ROOT_PASSWORD=Test@123
- MYSQL_DATABASE=BankDB
MYSQL_ROOT_PASSWORD: Test@123
MYSQL_DATABASE: bankappdb
ports:
Comment on lines +7 to +9

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Quote environment variable values.
Unquoted strings containing special characters (like @ in passwords or ? and & in URLs) can be misinterpreted by YAML parsers. For example:

MYSQL_ROOT_PASSWORD: "Test@123"
SPRING_DATASOURCE_URL: "jdbc:mysql://mysql:3306/bankappdb?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC"

- "3306:3306"
volumes:
- bankapp-volume:/var/lib/mysql
networks:
- bankapp
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 10s
timeout: 5s
retries: 3
start_period: 30s


mainapp:
image: ${DUSER}/${IMAGE}
container_name: Bankapp
image: bankapp:latest
container_name: "Bankapp"
environment:
- SPRING_DATASOURCE_USERNAME=root
- SPRING_DATASOURCE_URL=jdbc:mysql://mysql:3306/BankDB?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC
- SPRING_DATASOURCE_PASSWORD=Test@123
SPRING_DATASOURCE_USERNAME: root
SPRING_DATASOURCE_URL: jdbc:mysql://mysql:3306/bankappdb?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC
SPRING_DATASOURCE_PASSWORD: Test@123
Comment on lines +22 to +23

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Ensure port mapping matches the app’s exposed port.
The application now listens on port 8081 (per your Dockerfile and Kubernetes manifests), but this maps "8080:8080". Update to:

- - "8080:8080"
+ - "8081:8081"

Committable suggestion skipped: line range outside the PR's diff.

ports:
- "8080:8080"
depends_on:
mysql:
condition: service_healthy
- mysql
networks:
- bankapp
restart: always
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8080/actuator/health || exit 1"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s


networks:
bankapp:

volumes:
bankapp-volume:
bankapp-volume:
4 changes: 4 additions & 0 deletions kube/Namespace.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
kind: Namespace
apiVersion: v1
metadata:
name: bank
Comment on lines +1 to +4

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Consolidate duplicate Namespace manifests
It looks like the bank Namespace is defined here and also in kubernetes/bankapp-namespace.yaml. Maintaining two separate definitions can lead to drift and confusion—please consolidate into a single manifest.

38 changes: 38 additions & 0 deletions kube/bank-deployement.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
kind: Deployment
apiVersion: apps/v1
metadata:
name: bank-deployment
namespace: bank
labels:
app: app
Comment on lines +1 to +7

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Correct the misnamed file and unify resource naming.
The filename and resource (bank-deployement.yml) contain a typo (“deployement”) which may lead to confusion or broken references. Rename the file to bank-deployment.yml and update any related scripts or manifests.

spec:
replicas: 3
selector:
matchLabels:
app: app
template:
metadata:
labels:
app: app
spec:
containers:
- name: bank-cont
image: swayamnakshane/mybank:latest
ports:
- containerPort: 8081
env:
- name: SPRING_DATASOURCE_USERNAME
valueFrom:
configMapKeyRef:
name: bank-configmap
key: SPRING_DATASOURCE_USERNAME
- name: SPRING_DATASOURCE_URL
valueFrom:
configMapKeyRef:
name: bank-configmap
key: SPRING_DATASOURCE_URL
- name: SPRING_DATASOURCE_PASSWORD
valueFrom:
secretKeyRef:
name: bank-secret
key: SPRING_DATASOURCE_PASSWORD
16 changes: 16 additions & 0 deletions kube/bank-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
kind: Service
apiVersion: v1
metadata:
name: bank-svc
namespace: bank
labels:
app: app
spec:
type: NodePort
selector:
app: app
ports:
- protocol: TCP
targetPort: 8080
port: 8081
nodePort: 30080
Comment on lines +12 to +16

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Inconsistent target port vs. container port
The Service’s targetPort: 8080 must match the container’s containerPort exposed by your bank-deployment. According to the PR summary and Dockerfile changes, the application listens on port 8081, so this should be aligned.

Please verify the container port in kube/bank-deployement.yml (or the Dockerfile) and update targetPort accordingly:

 spec:
   ports:
     - protocol: TCP
-      targetPort: 8080
+      targetPort: 8081
       port: 8081
       nodePort: 30080
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ports:
- protocol: TCP
targetPort: 8080
port: 8081
nodePort: 30080
spec:
ports:
- protocol: TCP
targetPort: 8081
port: 8081
nodePort: 30080

10 changes: 10 additions & 0 deletions kube/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
image: kindest/node:v1.31.2
- role: worker
image: kindest/node:v1.31.2
- role: worker
image: kindest/node:v1.31.2

9 changes: 9 additions & 0 deletions kube/configmap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: bank-configmap
namespace: bank
data:
MYSQL_DATABASE: bankappdb
SPRING_DATASOURCE_USERNAME: root
SPRING_DATASOURCE_URL: jdbc:mysql://mysql:3306/bankappdb?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC
44 changes: 44 additions & 0 deletions kube/mysql-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mysql-deployment
namespace: bank
labels:
app: bankapp
annotations:
argocd.argoproj.io/sync-options: Replace=true
spec:
serviceName: mysql
replicas: 2
selector:
matchLabels:
app: bankapp
template:
metadata:
labels:
app: bankapp
spec:
containers:
- name: mysql
image: mysql:latest
ports:
Comment on lines +23 to +24

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Avoid using the latest image tag for MySQL.
Pin the MySQL image to a specific version (e.g., mysql:8.0.33) to ensure reproducible, stable deployments and simplify rollback procedures.

- containerPort: 3306
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: bank-secret
key: MYSQL_ROOT_PASSWORD
- name: MYSQL_DATABASE
valueFrom:
configMapKeyRef:
name: bank-configmap
key: MYSQL_DATABASE
volumeMounts:
- name: mysql
mountPath: /var/lib/mysql

volumes:
- name: mysql-persistent-storage
persistentVolumeClaim:
claimName: mysql-pvc
17 changes: 17 additions & 0 deletions kube/mysql-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
name: mysql
namespace: bank
labels:
app: bankapp

spec:
clusterIP: None
selector:
app: bankapp
ports:
- protocol: TCP
port: 3306
targetPort: 3306

16 changes: 16 additions & 0 deletions kube/persistentvolume.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: mysql-pv
namespace: bank
labels:
Comment on lines +4 to +6

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

❓ Verification inconclusive

Remove unsupported namespace and add reclaim policy
PersistentVolumes are cluster-scoped and ignore the metadata.namespace field—please remove it. It’s also best practice to explicitly set a persistentVolumeReclaimPolicy (e.g., Retain or Delete) and add a type for the hostPath (e.g., DirectoryOrCreate) to ensure the directory exists.

Proposed diff:

 metadata:
   name: mysql-pv
-  namespace: bank
   labels:
     app: bankapp
 spec:
+  persistentVolumeReclaimPolicy: Retain
   storageClassName: standard
   capacity:
     storage: 5Gi
   accessModes:
     - ReadWriteOnce
   hostPath:
     path: "/mnt/data/mysql"
+    type: DirectoryOrCreate

Also applies to: 14-15


Remove unsupported namespace and explicitly set reclaim policy & hostPath type

PersistentVolumes are cluster-scoped, so metadata.namespace is ignored—please remove it. It’s also best practice to specify a persistentVolumeReclaimPolicy (e.g. Retain) and a hostPath.type (e.g. DirectoryOrCreate) to ensure the directory exists.

Locations to update:

  • kube/persistentvolume.yml, metadata block (remove namespace: bank)
  • kube/persistentvolume.yml, spec block (add reclaim policy)
  • kube/persistentvolume.yml, hostPath block (add type)
  • Also apply the same changes at lines 14–15 for the second PersistentVolume

Proposed diff:

 metadata:
   name: mysql-pv
-  namespace: bank
   labels:
     app: bankapp
 spec:
+  persistentVolumeReclaimPolicy: Retain
   storageClassName: standard
   capacity:
     storage: 5Gi
   accessModes:
     - ReadWriteOnce
   hostPath:
     path: "/mnt/data/mysql"
+    type: DirectoryOrCreate

app: bankapp
spec:
storageClassName: standard
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/data/mysql"

15 changes: 15 additions & 0 deletions kube/persistentvolumeclaim.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-pvc
namespace: bank
labels:
app: bankapp
spec:
storageClassName: standard
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi

9 changes: 9 additions & 0 deletions kube/secret.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: bank-secret
namespace: bank
type: opaque
data:
MYSQL_ROOT_PASSWORD: VGVzdEAxMjM=
SPRING_DATASOURCE_PASSWORD: VGVzdEAxMjM=
Comment on lines +7 to +9

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Avoid committing plaintext credentials
Storing base64-encoded passwords (Test@123) directly in version control poses a security risk. Consider using a sealed Secret (e.g., SealedSecret), an external vault, or Git-encrypted secrets to manage sensitive data.

4 changes: 4 additions & 0 deletions kubernetes/Namespace.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
kind: Namespace
apiVersion: v1
metadata:
name: bank
38 changes: 38 additions & 0 deletions kubernetes/bank-deployement.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
kind: Deployment
apiVersion: apps/v1
metadata:
name: bank-deployment
namespace: bank
Comment on lines +1 to +5

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix filename and resource naming typo.
As in the kube/ directory, rename this file and the metadata.name from bank-deployement to bank-deployment, and update any references.

labels:
app: app
spec:
replicas: 3
selector:
matchLabels:
app: app
template:
metadata:
labels:
app: app
spec:
containers:
- name: bank-cont
image: swayamnakshane/mybank:latest
ports:
- containerPort: 8081
env:
- name: SPRING_DATASOURCE_USERNAME
valueFrom:
configMapKeyRef:
name: bank-configmap
key: SPRING_DATASOURCE_USERNAME
- name: SPRING_DATASOURCE_URL
valueFrom:
configMapKeyRef:
name: bank-configmap
key: SPRING_DATASOURCE_URL
- name: SPRING_DATASOURCE_PASSWORD
valueFrom:
secretKeyRef:
name: bank-secret
key: SPRING_DATASOURCE_PASSWORD
16 changes: 16 additions & 0 deletions kubernetes/bank-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
kind: Service
apiVersion: v1
metadata:
name: bank-svc
namespace: bank
labels:
app: app
spec:
type: NodePort
selector:
app: app
ports:
- protocol: TCP
targetPort: 8080
port: 8081
nodePort: 30080
Comment on lines +13 to +16

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Critical: Service targetPort mismatch with container port.
Your Service maps nodePort: 30080 and port: 8081 to targetPort: 8080, but the application listens on 8081 (per your Dockerfile). This mismatch will break traffic routing.

Apply this diff to correct it:

 spec:
   type: NodePort
   selector:
     app: app
   ports:
     - protocol: TCP
-      targetPort: 8080
+      targetPort: 8081
       port: 8081
       nodePort: 30080
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- protocol: TCP
targetPort: 8080
port: 8081
nodePort: 30080
spec:
type: NodePort
selector:
app: app
ports:
- protocol: TCP
targetPort: 8081
port: 8081
nodePort: 30080

Loading