-
Notifications
You must be signed in to change notification settings - Fork 367
Kube #30
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?
Kube #30
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
1b5fc72
f241fe1
79468f6
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,4 @@ | ||
| kind: Namespace | ||
| apiVersion: v1 | ||
| metadata: | ||
| name: bank |
| 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: | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+3
to
+6
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. 🛠️ Refactor suggestion File naming and metadata consistency |
||||||||||||||||||||||||||||||||||||||
| 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: | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+19
to
+23
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. 🛠️ Refactor suggestion Explicitly set Apply this diff: spec:
containers:
- name: bank-cont
image: swayamnakshane/mybank:latest
+ imagePullPolicy: Always
+ resources:
+ requests:
+ cpu: "100m"
+ memory: "256Mi"
+ limits:
+ cpu: "500m"
+ memory: "512Mi"📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||
| - 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 | ||||||||||||||||||||||||||||||||||||||
| 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
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 mapping consistency. 🏁 Script executed: #!/bin/bash
set -e
# Locate the Deployment manifest(s) for the bank service and check container ports
rg -n "containerPort" -g "kube/bank*.yml"Length of output: 111 Update Service targetPort to match Deployment’s containerPort The Deployment in • kube/bank-deployement.yml (line 22):
Suggested change: --- a/kube/bank-service.yml
+++ a/kube/bank-service.yml
@@ -13,3 +13,3 @@
- targetPort: 8080
+ targetPort: 8081📝 Committable suggestion
Suggested change
|
||||||||||||||||||
| 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 | ||
|
|
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| apiVersion: apps/v1 | ||
| kind: StatefulSet | ||
| metadata: | ||
| name: mysql-deployment | ||
| namespace: bank | ||
| labels: | ||
| app: bankapp | ||
| spec: | ||
| serviceName: mysql | ||
| replicas: 2 | ||
| selector: | ||
| matchLabels: | ||
| app: bankapp | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app: bankapp | ||
| spec: | ||
| containers: | ||
| - name: mysql | ||
| image: mysql:latest | ||
| ports: | ||
| - containerPort: 3306 | ||
|
Comment on lines
+20
to
+23
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. 🛠️ Refactor suggestion Avoid using the |
||
| 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 | ||
|
|
||
| volumeClaimTemplates: | ||
| - metadata: | ||
| name: mysql | ||
| labels: | ||
| app: bankapp | ||
| spec: | ||
| accessModes: | ||
| - ReadWriteOnce | ||
| resources: | ||
| requests: | ||
| storage: 5Gi | ||
|
|
||
| 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 | ||
|
|
| 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: | ||
| app: bankapp | ||
|
Comment on lines
+4
to
+7
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. Remove Apply this diff: metadata:
name: mysql-pv
- namespace: bank
labels:
app: bankapp |
||
| spec: | ||
| storageClassName: standard | ||
| capacity: | ||
| storage: 5Gi | ||
| accessModes: | ||
| - ReadWriteOnce | ||
| hostPath: | ||
| path: "/mnt/data/mysql" | ||
|
|
||
| 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= |
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.
Port mismatch: container expects 8081
The Kubernetes manifest and Dockerfile expose port 8081, but this service maps
8080:8080. This inconsistency will break connectivity. Update to:📝 Committable suggestion