Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
267 changes: 0 additions & 267 deletions k8s/README.md

This file was deleted.

44 changes: 19 additions & 25 deletions k8s/backend-deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: backend
name: backend-deployment
namespace: chat-app
spec:
replicas: 1
Expand All @@ -10,31 +10,25 @@ spec:
app: backend
template:
metadata:
name: backend-pod
namespace: chat-app
labels:
app: backend
spec:
containers:
- name: backend
image: iemafzal/backend:v1
imagePullPolicy: Always
ports:
- containerPort: 5001
env:
- name: MONGODB_URI
value: "mongodb://root:admin@mongodb:27017/chatApp?authSource=admin"
- name: PORT
value: "5001"
- name: NODE_ENV
value: "production"
- name: JWT_SECRET
valueFrom:
secretKeyRef:
name: backend-secrets
key: jwt-secret
resources:
limits:
memory: "512Mi"
cpu: "500m"
requests:
memory: "256Mi"
cpu: "250m"
- name: chatapp-backend
image: polepallivarun/chatapp-backend:latest
ports:
- containerPort: 5001
env:
- name: MONGODB_URI
value: "mongodb://mongoadmin:secret123@mongodb-service:27017/chatapp?authSource=admin&retryWrites=true&w=majority"
Comment on lines +24 to +25
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Extract MongoDB credentials from the connection string into secrets.

The MONGODB_URI contains plaintext credentials (mongoadmin:secret123). Checkov flagged this as CKV_SECRET_4. Consider:

  1. Store MongoDB credentials in the secret alongside jwt-secret
  2. Construct the URI using multiple env vars or use init containers

Alternatively, use string interpolation with secret-backed env vars if the application supports it.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@k8s/backend-deployment.yaml` around lines 24 - 25, The MONGODB_URI currently
embeds plaintext credentials; extract the username/password into a Kubernetes
Secret (add keys like mongodb-username and mongodb-password alongside the
existing jwt-secret) and update the Deployment to stop hardcoding credentials by
replacing the single MONGODB_URI env var with either (a) separate env vars
MONGODB_USER and MONGODB_PASSWORD (and MONGODB_HOST/DB) sourced from the new
Secret and construct the URI in the app, or (b) construct MONGODB_URI from
secret-backed env vars via the container's command/args or an init container;
modify the env var named MONGODB_URI in the manifest to reference secretRef env
vars instead of the literal "mongodb://mongoadmin:secret123@..." string so
credentials are no longer in plaintext.

- name: PORT
value: "5001"
- name: NODE_ENV
value: production
- name: JWT_SECRET
valueFrom:
secretKeyRef:
name: chatapp-secrets
key: jwt-secret
8 changes: 0 additions & 8 deletions k8s/backend-secrets.yaml

This file was deleted.

7 changes: 2 additions & 5 deletions k8s/backend-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,5 @@ spec:
selector:
app: backend
ports:
- protocol: TCP
port: 5001
targetPort: 5001
nodePort: 30501
type: NodePort
- port: 5001
targetPort: 5001
39 changes: 0 additions & 39 deletions k8s/frontend-configmap.yaml

This file was deleted.

Loading