-
Notifications
You must be signed in to change notification settings - Fork 378
K8s #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: DevOps
Are you sure you want to change the base?
K8s #27
Changes from all commits
0977b7e
157c4f6
df53f74
3eb7751
43b6b2a
a291f89
6837bfe
96ef1f2
a71528a
e9d9390
3ff137e
1574abe
7f3a681
c540fd6
b5e8149
e6c9727
6e8aee2
86ad8bd
d0a31ff
502420f
02d37d5
dfdfd18
c56bbe9
ddcb169
15d0f21
37b6c4e
e0b3c45
cb930ce
ccff992
d0b6471
64223fb
5f2c13e
7d724c0
b02e0a8
1bc0ed5
f3357df
61224b9
e852e2f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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"] |
| 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 | ||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct -spec:
- replica: 3
+spec:
+ replicas: 3📝 Committable suggestion
Suggested change
|
||||||||||||||||||||
| 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use Secret reference for database password - - 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
Suggested change
|
||||||||||||||||||||
| resources: | ||||||||||||||||||||
| limits: | ||||||||||||||||||||
| cpu: "1" | ||||||||||||||||||||
| memory: "512Mi" | ||||||||||||||||||||
| requests: | ||||||||||||||||||||
| cpu: "0.5" | ||||||||||||||||||||
| memory: "256Mi" | ||||||||||||||||||||
| 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 | ||
|
|
| 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 | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify container port matches Dockerfile 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 - - containerPort: 8080
+ - containerPort: 8081📝 Committable suggestion
Suggested change
🧰 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct Secret vs ConfigMap refs and names
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
|
||||||
|
|
||||||
|
|
||||||
| # 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" | ||||||
|
|
||||||
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,4 @@ | ||
| apiVersion: v1 | ||
| kind: Namespace | ||
| apiVersion: v1 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainConfirm namespace renaming and manifest consistency. 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
Ensure every |
||
| metadata: | ||
| name: bankapp-namespace | ||
| labels: | ||
| name: bankapp-namespace | ||
| name: bank | ||
| 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 | ||
|
|
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,10 @@ | ||||||
| kind: clster | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct the Apply this diff: @@ -1,1 +1,1 @@
-kind: clster
+kind: Cluster📝 Committable suggestion
Suggested change
|
||||||
| 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 | ||||||
| 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 | ||
|
|
| 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid committing plaintext credentials
The root password
Test@123is hard‑coded in your Compose file. This exposes sensitive data. Consider using Docker secrets or environment files (.env) to inject credentials securely.