Skip to content
Open

K8s #27

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 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
61224b9
new kubernetes files
Apr 18, 2025
e852e2f
new image
Apr 18, 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
container_name: mysql
environment:
- MYSQL_ROOT_PASSWORD=Test@123
- MYSQL_DATABASE=BankDB
MYSQL_ROOT_PASSWORD: Test@123
MYSQL_DATABASE: bankappdb
Comment on lines +7 to +8

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
The root password Test@123 is hard‑coded in your Compose file. This exposes sensitive data. Consider using Docker secrets or environment files (.env) to inject credentials securely.

ports:
- "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
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:
45 changes: 45 additions & 0 deletions kubernetes/bank-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: bank-deployment
namespace: bank
labels:
app: bankapp
spec:
replica: 3

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 replica field to replicas
The field replica: 3 is invalid—it should be replicas: 3—otherwise Kubernetes will ignore your replica count.

-spec:
-  replica: 3
+spec:
+  replicas: 3
📝 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
replica: 3
spec:
replicas: 3

selector:
matchLabels:
app: bankapp
template:
metadata:
labels:
app: bankapp
spec:
containers:
- name: mybank
image: swayamnakshane/mybank:latest
ports:
- containerPort: 8080
environment:
- name: SPRING_DATASOURCE_USERNAME
valueFrom:
configMapKeyRef:
name: bank-config
key: SPRING_DATASOURCE_USERNAME
- name: SPRING_DATASOURCE_URL
valueFrom:
configMapKeyRef:
name: bank-config
key: SPRING_DATASOURCE_URL
- name: SPRING_DATASOURCE_PASSWORD
valueFrom:
configMapKeyRef:
name: bank-secret
key: SPRING_DATASOURCE_PASSWORD
Comment on lines +35 to +38

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

Use Secret reference for database password
You’re using configMapKeyRef to pull SPRING_DATASOURCE_PASSWORD from bank-secret; this must be secretKeyRef. Otherwise, the password won’t be loaded.

-        - name: SPRING_DATASOURCE_PASSWORD
-          valueFrom:
-            configMapKeyRef:
-               name: bank-secret
-               key: SPRING_DATASOURCE_PASSWORD
+        - name: SPRING_DATASOURCE_PASSWORD
+          valueFrom:
+            secretKeyRef:
+               name: bank-secret
+               key: SPRING_DATASOURCE_PASSWORD
📝 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
valueFrom:
configMapKeyRef:
name: bank-secret
key: SPRING_DATASOURCE_PASSWORD
- name: SPRING_DATASOURCE_PASSWORD
valueFrom:
secretKeyRef:
name: bank-secret
key: SPRING_DATASOURCE_PASSWORD

resources:
limits:
cpu: "1"
memory: "512Mi"
requests:
cpu: "0.5"
memory: "256Mi"
13 changes: 13 additions & 0 deletions kubernetes/bank-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: bank-service
namespace: bank
spec:
selector:
app: bankapp
ports:
- protocol: TCP
port: 8080
targetPort: 8080

76 changes: 40 additions & 36 deletions kubernetes/bankapp-deployment.yml
Original file line number Diff line number Diff line change
@@ -1,63 +1,67 @@
apiVersion: apps/v1
kind: Deployment
apiVersion: apps/v1
metadata:
name: bank-deployment
namespace: bank
labels:
app: bankapp-deploy
name: bankapp-deploy
namespace: bankapp-namespace
app: bankapp
spec:
replicas: 2 # Keep replicas >= 2 for high availability
replicas: 3
selector:
matchLabels:
app: bankapp-deploy
app: bankapp
template:
metadata:
labels:
app: bankapp-deploy
app: bankapp
spec:
containers:
- name: bankapp
image: trainwithshubham/bankapp-eks:v2
- name: bank-pod
image: swayamnakshane/bank
ports:
- containerPort: 8080
- containerPort: 8080

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

🧩 Analysis chain

Verify container port matches Dockerfile
The containerPort is set to 8080, but the updated Dockerfile may expose 8081. Please verify and update to the correct port or adjust your Dockerfile accordingly.

Run this script to confirm the exposed port:


🏁 Script executed:

#!/bin/bash
# Check which port is exposed in the Dockerfile
rg -n '^EXPOSE' .

Length of output: 47


Update containerPort to match Dockerfile

The Dockerfile exposes port 8081, but the Kubernetes manifest still uses 8080. Please align them by updating the deployment spec.

• File: kubernetes/bankapp-deployment.yml
• Line: 22

-          - containerPort: 8080
+          - containerPort: 8081
📝 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
- containerPort: 8080
- containerPort: 8081
🧰 Tools
🪛 YAMLlint (1.35.1)

[warning] 22-22: wrong indentation: expected 8 but found 10

(indentation)



env:
- name: SPRING_DATASOURCE_URL
- name: SPRING_DATASOURCE_PASSWORD
valueFrom:
configMapKeyRef:
name: bankapp-config
key: SPRING_DATASOURCE_URL
secretKeyRef:
name: bank-secret
key: SPRING_DATASOURCE_PASSWORD

- name: SPRING_DATASOURCE_USERNAME
valueFrom:
configMapKeyRef:
name: bankapp-config
name: bank-configmap
key: SPRING_DATASOURCE_USERNAME
- name: MYSQL_DATABASE

- name: SPRING_DATASOURCE_URL
valueFrom:
configMapKeyRef:
name: bankapp-config
key: MYSQL_DATABASE
- name: SPRING_DATASOURCE_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-secret
key: SPRING_DATASOURCE_PASSWORD
# readinessProbe:
# httpGet:
# path: /actuator/health # Update this based on your app's health endpoint
# port: 8080
# initialDelaySeconds: 10
# periodSeconds: 5
# livenessProbe:
# httpGet:
# path: /actuator/health # Update this based on your app's health endpoint
# port: 8080
# initialDelaySeconds: 30
# periodSeconds: 10
name: bank-configmap
key: SPRING_DATASOURCE_URL
Comment on lines 25 to +42

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 Secret vs ConfigMap refs and names

  • The password is pulled via configMapKeyRef from bank-secret—this must be secretKeyRef.
  • The ConfigMap name bank-configmap doesn’t match the actual ConfigMap bank-config.

These mismatches will prevent your app from getting credentials.

-        - name: SPRING_DATASOURCE_PASSWORD
-          valueFrom:
-            configMapKeyRef:
-              name: bank-secret
-              key: SPRING_DATASOURCE_PASSWORD
+        - name: SPRING_DATASOURCE_PASSWORD
+          valueFrom:
+            secretKeyRef:
+              name: bank-secret
+              key: SPRING_DATASOURCE_PASSWORD

-        - name: SPRING_DATASOURCE_USERNAME
-          valueFrom:
-            configMapKeyRef:
-              name: bank-configmap
-              key: SPRING_DATASOURCE_USERNAME
+        - name: SPRING_DATASOURCE_USERNAME
+          valueFrom:
+            configMapKeyRef:
+              name: bank-config
+              key: SPRING_DATASOURCE_USERNAME

-        - name: SPRING_DATASOURCE_URL
-          valueFrom:
-            configMapKeyRef:
-              name: bank-configmap
-              key: SPRING_DATASOURCE_URL
+        - name: SPRING_DATASOURCE_URL
+          valueFrom:
+            configMapKeyRef:
+              name: bank-config
+              key: SPRING_DATASOURCE_URL

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



# livenessProbe:
# httpGet:
# path: /actuator/health
# port: 8080
# initialDelaySeconds: 10
# periodSeconds: 5
# failureThreshold: 3
#
# readinessProbe:
# httpGet:
# path: /actuator/health
# port: 8080
# initialDelaySeconds: 5
# periodSeconds: 5
# failureThreshold: 3

resources:
requests:
memory: "512Mi"
cpu: "250m"
limits:
memory: "1Gi"
cpu: "500m"

19 changes: 0 additions & 19 deletions kubernetes/bankapp-hpa.yml

This file was deleted.

28 changes: 0 additions & 28 deletions kubernetes/bankapp-ingress.yml

This file was deleted.

6 changes: 2 additions & 4 deletions kubernetes/bankapp-namespace.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
apiVersion: v1
kind: Namespace
apiVersion: v1

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

🧩 Analysis chain

Confirm namespace renaming and manifest consistency.
The namespace was renamed from bankapp-namespace to bank and the apiVersion/kind order change is harmless. Ensure all Kubernetes manifests and tooling (Helm charts, scripts, GitOps config, etc.) reference the new namespace.

Run this from the repo root to catch any stray references:

Also applies to: 4-4


🏁 Script executed:

#!/bin/bash
rg -n "bankapp-namespace"

Length of output: 2179


Update lingering references to the old namespace
Your rename from bankapp-namespace to bank is correct, but there are still stray references in docs and Helm charts. Please update all of the following to use bank instead:

  • kubernetes/README.md
    • Line 127: --dest-namespace bankapp-namespace
    • Line 208: kubectl get certificate -n bankapp-namespace
    • Line 217: kubectl get all -n bankapp-namespace
    • Line 238: kubectl top pods -n bankapp-namespace
  • helm/bankapp/values.yaml (line 2: namespace: bankapp-namespace)
  • helm/bankapp/templates/
    • vpa.yaml (namespace default)
    • secrets.yml
    • service.yml
    • persistentVolumeClaim.yml
    • persistentVolume.yml
    • namespace.yml
    • mysqlStatefulSet.yml
    • mysqlService.yml
    • ingress.yml
    • hpa.yaml
    • deployment.yml
    • configMap.yml (including the SPRING_DATASOURCE_URL host)

Ensure every default "bankapp-namespace" and hard‑coded bankapp-namespace is replaced with bank.

metadata:
name: bankapp-namespace
labels:
name: bankapp-namespace
name: bank
18 changes: 9 additions & 9 deletions kubernetes/bankapp-service.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
apiVersion: v1
kind: Service
apiVersion: v1
metadata:
name: bankapp-service
namespace: bankapp-namespace
labels:
app: bankapp
name: bank-svc
namespace: bank
spec:
selector:
app: bankapp-deploy
app: bankapp
ports:
- protocol: TCP
port: 8080
targetPort: 8080
- protocol: TCP
targetPort: 8080
port: 8080
nodePort: 30080
type: NodePort

10 changes: 10 additions & 0 deletions kubernetes/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
kind: clster

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 kind typo to Cluster.
The field kind: clster is misspelled and will prevent the kind cluster from provisioning. It should read Cluster.

Apply this diff:

@@ -1,1 +1,1 @@
-kind: clster
+kind: Cluster
📝 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
kind: clster
kind: Cluster

apiVersion: kind.x-k8s.io/v1alpha4

nodes:
- role: control-plane
image: kindest/node:1.31.2
- role: worker
image: kindest/node:1.31.2
- role: worker
image: kindest/node:1.31.2
10 changes: 10 additions & 0 deletions kubernetes/configMap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: bank-config
namespace: bank
data:
MYSQL_DATABASE: bankappdb
SPRING_DATASOURCE_USERNAME: root
SPRING_DATASOURCE_URL: jdbc:mysql://mysql:3306/bankappdb?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC

10 changes: 5 additions & 5 deletions kubernetes/configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
apiVersion: v1
kind: ConfigMap
apiVersion: v1
metadata:
name: bankapp-config
namespace: bankapp-namespace
name: bank-configmap
namespace: bank
data:
MYSQL_DATABASE: BankDB
SPRING_DATASOURCE_URL: jdbc:mysql://mysql-svc.bankapp-namespace.svc.cluster.local:3306/BankDB?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC
MYSQL_DATABASE: bankappdb
SPRING_DATASOURCE_USERNAME: root
SPRING_DATASOURCE_URL: jdbc:mysql://mysql:3306/bankappdb?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC
Loading