-
Notifications
You must be signed in to change notification settings - Fork 1.3k
modified k8s manifests for minikube compatibility and project needs #9
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: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,33 @@ | ||||||||||||||||
| apiVersion: apps/v1 | ||||||||||||||||
| kind: Deployment | ||||||||||||||||
| metadata: | ||||||||||||||||
| name: backend-deployment | ||||||||||||||||
| namespace: chat-app | ||||||||||||||||
| spec: | ||||||||||||||||
| replicas: 1 | ||||||||||||||||
| selector: | ||||||||||||||||
| matchLabels: | ||||||||||||||||
| app: backend | ||||||||||||||||
| template: | ||||||||||||||||
| metadata: | ||||||||||||||||
| name: backend-pod | ||||||||||||||||
| labels: | ||||||||||||||||
| app: backend | ||||||||||||||||
| spec: | ||||||||||||||||
| containers: | ||||||||||||||||
| - name: chat-backend | ||||||||||||||||
| image: abhay41/chatapp-backend:latest | ||||||||||||||||
| ports: | ||||||||||||||||
| - containerPort: 5001 | ||||||||||||||||
| env: | ||||||||||||||||
| - name: NODE_ENV | ||||||||||||||||
| value: "production" | ||||||||||||||||
| - name: MONGODB_URI | ||||||||||||||||
| value: "mongodb://root:admin@mongodb-service:27017/chatApp?authSource=admin&retryWrites=true&w=majority" | ||||||||||||||||
|
Comment on lines
+25
to
+26
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. Hard-coded DB credentials leak secrets – move the entire URI to a Secret. - - name: MONGODB_URI
- value: "mongodb://root:admin@mongodb-service:27017/chatApp?authSource=admin&retryWrites=true&w=majority"
+ - name: MONGODB_URI
+ valueFrom:
+ secretKeyRef:
+ name: chatapp-secrets
+ key: mongodb-uri📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||
| - name: PORT | ||||||||||||||||
| value: "5001" | ||||||||||||||||
| - name: JWT_SECRET | ||||||||||||||||
| valueFrom: | ||||||||||||||||
| secretKeyRef: | ||||||||||||||||
| name: chatapp-secrets | ||||||||||||||||
| key: jwt | ||||||||||||||||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,12 @@ | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| metadata: | ||
| name: backend | ||
| namespace: chat-app | ||
| spec: | ||
| selector: | ||
| app: backend | ||
| ports: | ||
| - protocol: TCP | ||
| port: 5001 | ||
| targetPort: 5001 | ||
| nodePort: 30501 | ||
| type: NodePort | ||
| port: 5001 # Port exposed inside the cluster | ||
| targetPort: 5001 # Matches container port |
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.
🛠️ Refactor suggestion
Add a securityContext to drop root privileges and disallow privilege escalation.
Static analysis (CKV_K8S_20 / 23) flags the container as running as root. Harden it:
containers: - name: chat-backend image: abhay41/chatapp-backend:latest + securityContext: + runAsUser: 1000 + runAsNonRoot: true + allowPrivilegeEscalation: false ports: - containerPort: 5001📝 Committable suggestion
🤖 Prompt for AI Agents