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
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
OPENAI_API_KEY=sk-...
LOGOS_KEY=lg-...
4 changes: 3 additions & 1 deletion .github/workflows/deploy-k8s.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ jobs:
--set userService.image.tag=${{ steps.vars.outputs.image_tag }} \
--set groceryService.image.tag=${{ steps.vars.outputs.image_tag }} \
--set genai.image.tag=${{ steps.vars.outputs.image_tag }} \
--set userDb.image.tag=${{ steps.vars.outputs.image_tag }} \
--set groceryDb.image.tag=${{ steps.vars.outputs.image_tag }} \
--set genai.logosKey="${{ secrets.LOGOS_KEY }}" \
--set genai.openaiApiKey="${{ secrets.OPENAI_API_KEY }}" \
--set userDb.password="${{ secrets.USER_DB_PASSWORD }}" \
--set groceryDb.password="${{ secrets.GROCERY_DB_PASSWORD }}" \
--atomic
--set jwt.secret="${{ secrets.JWT_SECRET }}"
5 changes: 3 additions & 2 deletions .github/workflows/test-build-push.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Test, Build and Push Images

# Runs tests and builds images on every branch. Only pushes to the registry on main.
# Runs tests and builds images on every branch.
# Pushes to the registry only on main, or on a manual workflow_dispatch run.
on:
push:
branches:
Expand Down Expand Up @@ -93,7 +94,7 @@ jobs:
with:
context: ${{ matrix.context }}
file: ${{ matrix.context }}/Dockerfile
push: ${{ github.ref == 'refs/heads/main' }}
push: ${{ github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
Expand Down
9 changes: 9 additions & 0 deletions helm/bytebite/templates/api-gateway-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,12 @@ spec:
value: "http://grocery-service:{{ .Values.groceryService.service.port }}"
- name: USER_SERVICE_BASE_URL
value: "http://user-service:{{ .Values.userService.service.port }}"
{{- if .Values.jwt.secret }}
# Shared JWT secret (verifies tokens). Must match user-service. Only
# injected when set; otherwise the app's built-in default applies.
- name: JWT_SECRET
valueFrom:
secretKeyRef:
name: jwt-secret
key: jwt-secret
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
apiVersion: apps/v1
kind: StatefulSet
kind: Deployment
metadata:
name: bytebite-grocery-db
namespace: {{ .Values.namespace }}
spec:
serviceName: grocery-db
replicas: 1
# Ephemeral DB (emptyDir): recreate the pod rather than rolling, so two
# instances never run at once and each start gets a clean database.
strategy:
type: Recreate
selector:
matchLabels:
app: bytebite-grocery-db
Expand All @@ -18,6 +21,13 @@ spec:
- name: grocery-db
image: "{{ .Values.groceryDb.image.repository }}:{{ .Values.groceryDb.image.tag }}"
imagePullPolicy: {{ .Values.groceryDb.image.pullPolicy }}
resources:
limits:
cpu: "250m"
memory: "256Mi"
requests:
cpu: "100m"
memory: "128Mi"
ports:
- containerPort: 5432
env:
Expand All @@ -33,11 +43,7 @@ spec:
volumeMounts:
- name: grocery-db-data
mountPath: /var/lib/postgresql/data
volumeClaimTemplates:
- metadata:
name: grocery-db-data
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 1Gi
volumes:
# Ephemeral storage: the database is recreated on every pod start.
- name: grocery-db-data
emptyDir: {}
4 changes: 4 additions & 0 deletions helm/bytebite/templates/grocery-service-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ spec:
ports:
- containerPort: {{ .Values.groceryService.service.targetPort }}
env:
# The app's dev default port is 8082; override it so it listens on
# the container/Service port (8080), matching the api-gateway route.
- name: SERVER_PORT
value: "{{ .Values.groceryService.service.targetPort }}"
- name: GENAI_BASE_URL
value: "http://genai-service:{{ .Values.genai.service.port }}"
- name: SPRING_DATASOURCE_URL
Expand Down
13 changes: 12 additions & 1 deletion helm/bytebite/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,15 @@ metadata:
type: Opaque
data:
user-db-password: {{ .Values.userDb.password | b64enc | quote }}
grocery-db-password: {{ .Values.groceryDb.password | b64enc | quote }}
grocery-db-password: {{ .Values.groceryDb.password | b64enc | quote }}
{{- if .Values.jwt.secret }}
---
apiVersion: v1
kind: Secret
metadata:
name: jwt-secret
namespace: {{ .Values.namespace }}
type: Opaque
data:
jwt-secret: {{ .Values.jwt.secret | b64enc | quote }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
apiVersion: apps/v1
kind: StatefulSet
kind: Deployment
metadata:
name: bytebite-user-db
namespace: {{ .Values.namespace }}
spec:
serviceName: user-db
replicas: 1
# Ephemeral DB (emptyDir): recreate the pod rather than rolling, so two
# instances never run at once and each start gets a clean database.
strategy:
type: Recreate
selector:
matchLabels:
app: bytebite-user-db
Expand All @@ -18,6 +21,13 @@ spec:
- name: user-db
image: "{{ .Values.userDb.image.repository }}:{{ .Values.userDb.image.tag }}"
imagePullPolicy: {{ .Values.userDb.image.pullPolicy }}
resources:
limits:
cpu: "250m"
memory: "256Mi"
requests:
cpu: "100m"
memory: "128Mi"
ports:
- containerPort: 5432
env:
Expand All @@ -33,11 +43,7 @@ spec:
volumeMounts:
- name: user-db-data
mountPath: /var/lib/postgresql/data
volumeClaimTemplates:
- metadata:
name: user-db-data
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 1Gi
volumes:
# Ephemeral storage: the database is recreated on every pod start.
- name: user-db-data
emptyDir: {}
13 changes: 13 additions & 0 deletions helm/bytebite/templates/user-service-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ spec:
ports:
- containerPort: {{ .Values.userService.service.targetPort }}
env:
# The app's dev default port is 8083; override it so it listens on
# the container/Service port (8080), matching the api-gateway route.
- name: SERVER_PORT
value: "{{ .Values.userService.service.targetPort }}"
{{- if .Values.jwt.secret }}
# Shared JWT secret (signs tokens). Must match the api-gateway. Only
# injected when set; otherwise the app's built-in default applies.
- name: JWT_SECRET
valueFrom:
secretKeyRef:
name: jwt-secret
key: jwt-secret
{{- end }}
- name: SPRING_DATASOURCE_URL
value: "jdbc:postgresql://user-db:5432/{{ .Values.userDb.name }}"
- name: SPRING_DATASOURCE_USERNAME
Expand Down
6 changes: 6 additions & 0 deletions helm/bytebite/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ groceryDb:
user: bytebite_grocery
password: ""

# Shared JWT signing/verification secret for user-service (signs) and
# api-gateway (verifies). Must be >=32 chars. Leave empty to fall back to the
# apps' built-in dev default; set via --set jwt.secret / a GitHub secret for real deploys.
jwt:
secret: ""

ingress:
enabled: true
className: "nginx"
Expand Down
Loading