Skip to content

Commit 3c39a54

Browse files
committed
fix: Resolve CI/CD workflow issues in PR #261
- Fix staging workflow to skip deployment for PRs (no KUBECONFIG available) - Add informational job for PRs that builds images but skips deployment - Add disk space cleanup step to staging workflow - Create complete Helm chart templates: - Namespace, ConfigMap, Secrets - Backend and Frontend Deployments and Services - Ingress with TLS support - HorizontalPodAutoscaler for auto-scaling - Fix Helm template helpers and validation - All workflows now pass linting and are ready for deployment Resolves: PR #261 deployment failures
1 parent cac7479 commit 3c39a54

File tree

10 files changed

+414
-0
lines changed

10 files changed

+414
-0
lines changed

.github/workflows/k8s-deploy-staging.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ jobs:
2828
- name: Checkout code
2929
uses: actions/checkout@v4
3030

31+
- name: Free up disk space
32+
run: |
33+
sudo rm -rf /usr/share/dotnet
34+
sudo rm -rf /opt/ghc
35+
sudo rm -rf /usr/local/share/boost
36+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
37+
df -h
38+
3139
- name: Set up Docker Buildx
3240
uses: docker/setup-buildx-action@v3
3341

@@ -66,6 +74,7 @@ jobs:
6674
name: Deploy to Staging with Helm
6775
runs-on: ubuntu-latest
6876
needs: build-and-push
77+
if: github.event_name != 'pull_request'
6978
environment:
7079
name: staging
7180
url: https://rag-modulo-staging.example.com
@@ -136,3 +145,20 @@ jobs:
136145
repo: context.repo.repo,
137146
body: '✅ Deployed to staging environment successfully!\n\nAccess at: https://rag-modulo-staging.example.com'
138147
})
148+
149+
deployment-skipped:
150+
name: Deployment Skipped (No K8s Cluster)
151+
runs-on: ubuntu-latest
152+
needs: build-and-push
153+
if: github.event_name == 'pull_request'
154+
steps:
155+
- name: Comment on PR
156+
uses: actions/github-script@v7
157+
with:
158+
script: |
159+
github.rest.issues.createComment({
160+
issue_number: context.issue.number,
161+
owner: context.repo.owner,
162+
repo: context.repo.repo,
163+
body: '🚀 Docker images built and pushed successfully!\n\n⚠️ Deployment to staging skipped for PR (no Kubernetes cluster configured).\n\nImages available at:\n- Backend: `ghcr.io/manavgup/rag_modulo/backend:staging-${{ github.sha }}`\n- Frontend: `ghcr.io/manavgup/rag_modulo/frontend:staging-${{ github.sha }}`\n\nDeployment will run automatically when merged to `develop` or `staging` branches.'
164+
})

deployment/helm/rag-modulo/templates/_helpers.tpl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,14 @@ Return the appropriate apiVersion for HPA
6969
{{- print "autoscaling/v2beta2" }}
7070
{{- end }}
7171
{{- end }}
72+
73+
{{/*
74+
Create the namespace name
75+
*/}}
76+
{{- define "rag-modulo.namespace" -}}
77+
{{- if .Values.global.namespace }}
78+
{{- .Values.global.namespace }}
79+
{{- else }}
80+
{{- .Release.Namespace }}
81+
{{- end }}
82+
{{- end }}
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "rag-modulo.fullname" . }}-backend
5+
namespace: {{ include "rag-modulo.namespace" . }}
6+
labels:
7+
{{- include "rag-modulo.labels" . | nindent 4 }}
8+
app.kubernetes.io/component: backend
9+
spec:
10+
replicas: {{ .Values.backend.replicaCount | default 3 }}
11+
selector:
12+
matchLabels:
13+
{{- include "rag-modulo.selectorLabels" . | nindent 6 }}
14+
app.kubernetes.io/component: backend
15+
template:
16+
metadata:
17+
labels:
18+
{{- include "rag-modulo.selectorLabels" . | nindent 8 }}
19+
app.kubernetes.io/component: backend
20+
spec:
21+
containers:
22+
- name: backend
23+
image: "{{ .Values.images.backend.repository }}:{{ .Values.images.backend.tag | default .Chart.AppVersion }}"
24+
imagePullPolicy: {{ .Values.images.backend.pullPolicy | default "IfNotPresent" }}
25+
ports:
26+
- name: http
27+
containerPort: 8000
28+
protocol: TCP
29+
env:
30+
- name: COLLECTIONDB_HOST
31+
valueFrom:
32+
configMapKeyRef:
33+
name: {{ include "rag-modulo.fullname" . }}-config
34+
key: COLLECTIONDB_HOST
35+
- name: COLLECTIONDB_PORT
36+
valueFrom:
37+
configMapKeyRef:
38+
name: {{ include "rag-modulo.fullname" . }}-config
39+
key: COLLECTIONDB_PORT
40+
- name: COLLECTIONDB_NAME
41+
valueFrom:
42+
configMapKeyRef:
43+
name: {{ include "rag-modulo.fullname" . }}-config
44+
key: COLLECTIONDB_NAME
45+
- name: COLLECTIONDB_USER
46+
valueFrom:
47+
secretKeyRef:
48+
name: {{ .Values.secrets.name | default "rag-modulo-secrets" }}
49+
key: COLLECTIONDB_USER
50+
- name: COLLECTIONDB_PASSWORD
51+
valueFrom:
52+
secretKeyRef:
53+
name: {{ .Values.secrets.name | default "rag-modulo-secrets" }}
54+
key: COLLECTIONDB_PASSWORD
55+
- name: MILVUS_HOST
56+
valueFrom:
57+
configMapKeyRef:
58+
name: {{ include "rag-modulo.fullname" . }}-config
59+
key: MILVUS_HOST
60+
- name: MILVUS_PORT
61+
valueFrom:
62+
configMapKeyRef:
63+
name: {{ include "rag-modulo.fullname" . }}-config
64+
key: MILVUS_PORT
65+
- name: MINIO_ENDPOINT
66+
valueFrom:
67+
configMapKeyRef:
68+
name: {{ include "rag-modulo.fullname" . }}-config
69+
key: MINIO_ENDPOINT
70+
- name: MINIO_ROOT_USER
71+
valueFrom:
72+
secretKeyRef:
73+
name: {{ .Values.secrets.name | default "rag-modulo-secrets" }}
74+
key: MINIO_ROOT_USER
75+
- name: MINIO_ROOT_PASSWORD
76+
valueFrom:
77+
secretKeyRef:
78+
name: {{ .Values.secrets.name | default "rag-modulo-secrets" }}
79+
key: MINIO_ROOT_PASSWORD
80+
- name: JWT_SECRET_KEY
81+
valueFrom:
82+
secretKeyRef:
83+
name: {{ .Values.secrets.name | default "rag-modulo-secrets" }}
84+
key: JWT_SECRET_KEY
85+
- name: WATSONX_APIKEY
86+
valueFrom:
87+
secretKeyRef:
88+
name: {{ .Values.secrets.name | default "rag-modulo-secrets" }}
89+
key: WATSONX_APIKEY
90+
optional: true
91+
- name: WATSONX_PROJECT_ID
92+
valueFrom:
93+
secretKeyRef:
94+
name: {{ .Values.secrets.name | default "rag-modulo-secrets" }}
95+
key: WATSONX_PROJECT_ID
96+
optional: true
97+
- name: OPENAI_API_KEY
98+
valueFrom:
99+
secretKeyRef:
100+
name: {{ .Values.secrets.name | default "rag-modulo-secrets" }}
101+
key: OPENAI_API_KEY
102+
optional: true
103+
- name: ANTHROPIC_API_KEY
104+
valueFrom:
105+
secretKeyRef:
106+
name: {{ .Values.secrets.name | default "rag-modulo-secrets" }}
107+
key: ANTHROPIC_API_KEY
108+
optional: true
109+
resources:
110+
{{- toYaml .Values.backend.resources | nindent 12 }}
111+
livenessProbe:
112+
httpGet:
113+
path: /health
114+
port: http
115+
initialDelaySeconds: 30
116+
periodSeconds: 10
117+
timeoutSeconds: 5
118+
failureThreshold: 3
119+
readinessProbe:
120+
httpGet:
121+
path: /health
122+
port: http
123+
initialDelaySeconds: 5
124+
periodSeconds: 5
125+
timeoutSeconds: 3
126+
failureThreshold: 3
127+
{{- with .Values.backend.nodeSelector }}
128+
nodeSelector:
129+
{{- toYaml . | nindent 8 }}
130+
{{- end }}
131+
{{- with .Values.backend.affinity }}
132+
affinity:
133+
{{- toYaml . | nindent 8 }}
134+
{{- end }}
135+
{{- with .Values.backend.tolerations }}
136+
tolerations:
137+
{{- toYaml . | nindent 8 }}
138+
{{- end }}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "rag-modulo.fullname" . }}-backend
5+
namespace: {{ include "rag-modulo.namespace" . }}
6+
labels:
7+
{{- include "rag-modulo.labels" . | nindent 4 }}
8+
app.kubernetes.io/component: backend
9+
spec:
10+
type: ClusterIP
11+
ports:
12+
- port: 8000
13+
targetPort: http
14+
protocol: TCP
15+
name: http
16+
selector:
17+
{{- include "rag-modulo.selectorLabels" . | nindent 4 }}
18+
app.kubernetes.io/component: backend
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ include "rag-modulo.fullname" . }}-config
5+
namespace: {{ include "rag-modulo.namespace" . }}
6+
labels:
7+
{{- include "rag-modulo.labels" . | nindent 4 }}
8+
app.kubernetes.io/component: config
9+
data:
10+
COLLECTIONDB_HOST: "{{ .Values.postgresql.host | default "postgresql" }}"
11+
COLLECTIONDB_PORT: "{{ .Values.postgresql.port | default "5432" }}"
12+
COLLECTIONDB_NAME: "{{ .Values.postgresql.database | default "collectiondb" }}"
13+
MILVUS_HOST: "{{ .Values.milvus.host | default "milvus" }}"
14+
MILVUS_PORT: "{{ .Values.milvus.port | default "19530" }}"
15+
MINIO_ENDPOINT: "{{ .Values.minio.endpoint | default "minio:9000" }}"
16+
MLFLOW_TRACKING_URI: "{{ .Values.mlflow.trackingUri | default "http://mlflow:5000" }}"
17+
LOG_LEVEL: "{{ .Values.config.logLevel | default "INFO" }}"
18+
ENVIRONMENT: "{{ .Values.config.environment | default "production" }}"
19+
SKIP_AUTH: "{{ .Values.config.skipAuth | default "false" }}"
20+
DEVELOPMENT_MODE: "{{ .Values.config.developmentMode | default "false" }}"
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "rag-modulo.fullname" . }}-frontend
5+
namespace: {{ include "rag-modulo.namespace" . }}
6+
labels:
7+
{{- include "rag-modulo.labels" . | nindent 4 }}
8+
app.kubernetes.io/component: frontend
9+
spec:
10+
replicas: {{ .Values.frontend.replicaCount | default 2 }}
11+
selector:
12+
matchLabels:
13+
{{- include "rag-modulo.selectorLabels" . | nindent 6 }}
14+
app.kubernetes.io/component: frontend
15+
template:
16+
metadata:
17+
labels:
18+
{{- include "rag-modulo.selectorLabels" . | nindent 8 }}
19+
app.kubernetes.io/component: frontend
20+
spec:
21+
containers:
22+
- name: frontend
23+
image: "{{ .Values.images.frontend.repository }}:{{ .Values.images.frontend.tag | default .Chart.AppVersion }}"
24+
imagePullPolicy: {{ .Values.images.frontend.pullPolicy | default "IfNotPresent" }}
25+
ports:
26+
- name: http
27+
containerPort: 3000
28+
protocol: TCP
29+
env:
30+
- name: REACT_APP_API_URL
31+
value: "http://{{ include "rag-modulo.fullname" . }}-backend:8000"
32+
- name: REACT_APP_WS_URL
33+
value: "ws://{{ include "rag-modulo.fullname" . }}-backend:8000"
34+
resources:
35+
{{- toYaml .Values.frontend.resources | nindent 12 }}
36+
livenessProbe:
37+
httpGet:
38+
path: /
39+
port: http
40+
initialDelaySeconds: 30
41+
periodSeconds: 10
42+
timeoutSeconds: 5
43+
failureThreshold: 3
44+
readinessProbe:
45+
httpGet:
46+
path: /
47+
port: http
48+
initialDelaySeconds: 5
49+
periodSeconds: 5
50+
timeoutSeconds: 3
51+
failureThreshold: 3
52+
{{- with .Values.frontend.nodeSelector }}
53+
nodeSelector:
54+
{{- toYaml . | nindent 8 }}
55+
{{- end }}
56+
{{- with .Values.frontend.affinity }}
57+
affinity:
58+
{{- toYaml . | nindent 8 }}
59+
{{- end }}
60+
{{- with .Values.frontend.tolerations }}
61+
tolerations:
62+
{{- toYaml . | nindent 8 }}
63+
{{- end }}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "rag-modulo.fullname" . }}-frontend
5+
namespace: {{ include "rag-modulo.namespace" . }}
6+
labels:
7+
{{- include "rag-modulo.labels" . | nindent 4 }}
8+
app.kubernetes.io/component: frontend
9+
spec:
10+
type: ClusterIP
11+
ports:
12+
- port: 3000
13+
targetPort: http
14+
protocol: TCP
15+
name: http
16+
selector:
17+
{{- include "rag-modulo.selectorLabels" . | nindent 4 }}
18+
app.kubernetes.io/component: frontend
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{{- if .Values.backend.autoscaling.enabled }}
2+
apiVersion: autoscaling/v2
3+
kind: HorizontalPodAutoscaler
4+
metadata:
5+
name: {{ include "rag-modulo.fullname" . }}-backend
6+
namespace: {{ include "rag-modulo.namespace" . }}
7+
labels:
8+
{{- include "rag-modulo.labels" . | nindent 4 }}
9+
app.kubernetes.io/component: backend
10+
spec:
11+
scaleTargetRef:
12+
apiVersion: apps/v1
13+
kind: Deployment
14+
name: {{ include "rag-modulo.fullname" . }}-backend
15+
minReplicas: {{ .Values.backend.autoscaling.minReplicas | default 2 }}
16+
maxReplicas: {{ .Values.backend.autoscaling.maxReplicas | default 10 }}
17+
metrics:
18+
{{- if .Values.backend.autoscaling.targetCPUUtilizationPercentage }}
19+
- type: Resource
20+
resource:
21+
name: cpu
22+
target:
23+
type: Utilization
24+
averageUtilization: {{ .Values.backend.autoscaling.targetCPUUtilizationPercentage }}
25+
{{- end }}
26+
{{- if .Values.backend.autoscaling.targetMemoryUtilizationPercentage }}
27+
- type: Resource
28+
resource:
29+
name: memory
30+
target:
31+
type: Utilization
32+
averageUtilization: {{ .Values.backend.autoscaling.targetMemoryUtilizationPercentage }}
33+
{{- end }}
34+
{{- end }}
35+
36+
{{- if .Values.frontend.autoscaling.enabled }}
37+
---
38+
apiVersion: autoscaling/v2
39+
kind: HorizontalPodAutoscaler
40+
metadata:
41+
name: {{ include "rag-modulo.fullname" . }}-frontend
42+
namespace: {{ include "rag-modulo.namespace" . }}
43+
labels:
44+
{{- include "rag-modulo.labels" . | nindent 4 }}
45+
app.kubernetes.io/component: frontend
46+
spec:
47+
scaleTargetRef:
48+
apiVersion: apps/v1
49+
kind: Deployment
50+
name: {{ include "rag-modulo.fullname" . }}-frontend
51+
minReplicas: {{ .Values.frontend.autoscaling.minReplicas | default 2 }}
52+
maxReplicas: {{ .Values.frontend.autoscaling.maxReplicas | default 5 }}
53+
metrics:
54+
{{- if .Values.frontend.autoscaling.targetCPUUtilizationPercentage }}
55+
- type: Resource
56+
resource:
57+
name: cpu
58+
target:
59+
type: Utilization
60+
averageUtilization: {{ .Values.frontend.autoscaling.targetCPUUtilizationPercentage }}
61+
{{- end }}
62+
{{- if .Values.frontend.autoscaling.targetMemoryUtilizationPercentage }}
63+
- type: Resource
64+
resource:
65+
name: memory
66+
target:
67+
type: Utilization
68+
averageUtilization: {{ .Values.frontend.autoscaling.targetMemoryUtilizationPercentage }}
69+
{{- end }}
70+
{{- end }}

0 commit comments

Comments
 (0)