Skip to content

Commit 85235d2

Browse files
committed
Dev instance deployment and prod deployment fixes
1 parent fc17685 commit 85235d2

18 files changed

Lines changed: 221 additions & 59 deletions

File tree

.github/workflows/deploy-dev.yml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: Build & Deploy Dev
2+
3+
on:
4+
push:
5+
branches-ignore: [release]
6+
workflow_dispatch:
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
11+
jobs:
12+
build-and-push:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
packages: write
17+
18+
strategy:
19+
matrix:
20+
include:
21+
- service: user-service
22+
context: ./services/user-service
23+
- service: admin-service
24+
context: ./services/admin-service
25+
- service: checklist-service
26+
context: ./services/checklist-service
27+
- service: calendar-service
28+
context: ./services/calendar-service
29+
- service: note-service
30+
context: ./services/note-service
31+
- service: genai-service
32+
context: ./services/genai-service
33+
- service: client
34+
context: ./web-client
35+
build_args: |
36+
VITE_API_URL=/dev/api
37+
VITE_BASE_PATH=/dev
38+
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v4
42+
43+
- name: Log in to Container Registry
44+
uses: docker/login-action@v3
45+
with:
46+
registry: ${{ env.REGISTRY }}
47+
username: ${{ github.actor }}
48+
password: ${{ secrets.GITHUB_TOKEN }}
49+
50+
- name: Set up Docker Buildx
51+
uses: docker/setup-buildx-action@v3
52+
53+
- name: Build & push ${{ matrix.service }}
54+
uses: docker/build-push-action@v6
55+
with:
56+
context: ${{ matrix.context }}
57+
push: true
58+
tags: |
59+
${{ env.REGISTRY }}/aet-devops26/team-devopss26/${{ matrix.service }}:latest
60+
${{ env.REGISTRY }}/aet-devops26/team-devopss26/${{ matrix.service }}:${{ github.sha }}
61+
build-args: ${{ matrix.build_args }}
62+
63+
deploy-to-k8s:
64+
needs: build-and-push
65+
runs-on: ubuntu-latest
66+
steps:
67+
- name: Checkout
68+
uses: actions/checkout@v4
69+
70+
- name: Set up kubectl
71+
uses: azure/setup-kubectl@v3
72+
73+
- name: Set up Helm
74+
uses: azure/setup-helm@v4
75+
76+
- name: Configure kubectl
77+
run: |
78+
mkdir -p $HOME/.kube
79+
echo "${{ secrets.KUBECONFIG }}" | base64 -d > $HOME/.kube/config
80+
kubectl auth can-i get namespaces 2>&1 || true
81+
82+
- name: Deploy with Helm
83+
run: |
84+
helm upgrade --install devopss26-dev ./infra/iac/aet \
85+
--namespace team-devopss26-dev \
86+
--set global.imageTag=${{ github.sha }} \
87+
--set genaiService.geminiApiKey=${{ secrets.GEMINI_API_KEY }} \
88+
-f infra/iac/aet/values-dev.yaml \
89+
--timeout 5m
90+
91+
- name: Wait for rollout
92+
run: |
93+
for deploy in admin-service calendar-service checklist-service note-service user-service genai-service client; do
94+
echo "Waiting for $deploy..."
95+
kubectl rollout status deployment/$deploy -n team-devopss26-dev --timeout=5m
96+
done
97+
echo "Waiting for postgres..."
98+
kubectl rollout status statefulset/postgres -n team-devopss26-dev --timeout=5m
99+
echo "All deployments rolled out!"
100+
101+
- name: Verify deployment
102+
run: |
103+
TAG="${{ github.sha }}"
104+
echo "Checking pods are running image tag: $TAG"
105+
kubectl get pods -n team-devopss26-dev -o wide
106+
echo ""
107+
MISMATCH=0
108+
for pod in $(kubectl get pods -n team-devopss26-dev --no-headers -o name); do
109+
IMAGES=$(kubectl get -n team-devopss26-dev "$pod" -o jsonpath='{range .spec.containers[*]}{.image}{"\n"}{end}')
110+
while IFS= read -r img; do
111+
case "$img" in
112+
*postgres*) ;;
113+
*:$TAG) ;;
114+
*)
115+
echo "::warning::$pod has wrong image: $img (expected tag: $TAG)"
116+
MISMATCH=$((MISMATCH + 1))
117+
;;
118+
esac
119+
done <<< "$IMAGES"
120+
done
121+
if [ "$MISMATCH" -gt 0 ]; then
122+
echo "::error::$MISMATCH pods have wrong image tag"
123+
exit 1
124+
fi
125+
echo "All pods running expected images!"

.github/workflows/deploy.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ jobs:
9090
- name: Deploy with Helm
9191
run: |
9292
helm upgrade --install devopss26 ./infra/iac/aet \
93-
--namespace prod \
94-
--kubeconfig $HOME/.kube/config \
93+
--namespace team-devopss26-prod \
9594
--set global.imageTag=${{ github.sha }} \
9695
--set genaiService.geminiApiKey=${{ secrets.GEMINI_API_KEY }} \
9796
--set ingress.host=${{ vars.INGRESS_HOST }} \
@@ -102,21 +101,21 @@ jobs:
102101
run: |
103102
for deploy in admin-service calendar-service checklist-service note-service user-service genai-service client; do
104103
echo "Waiting for $deploy..."
105-
kubectl rollout status deployment/$deploy -n prod --timeout=5m
104+
kubectl rollout status deployment/$deploy -n team-devopss26-prod --timeout=5m
106105
done
107106
echo "Waiting for postgres..."
108-
kubectl rollout status statefulset/postgres -n prod --timeout=5m
107+
kubectl rollout status statefulset/postgres -n team-devopss26-prod --timeout=5m
109108
echo "All deployments rolled out!"
110109
111110
- name: Verify deployment
112111
run: |
113112
TAG="${{ github.sha }}"
114113
echo "Checking pods are running image tag: $TAG"
115-
kubectl get pods -n prod -o wide
114+
kubectl get pods -n team-devopss26-prod -o wide
116115
echo ""
117116
MISMATCH=0
118-
for pod in $(kubectl get pods -n prod --no-headers -o name); do
119-
IMAGES=$(kubectl get -n prod "$pod" -o jsonpath='{range .spec.containers[*]}{.image}{"\n"}{end}')
117+
for pod in $(kubectl get pods -n team-devopss26-prod --no-headers -o name); do
118+
IMAGES=$(kubectl get -n team-devopss26-prod "$pod" -o jsonpath='{range .spec.containers[*]}{.image}{"\n"}{end}')
120119
while IFS= read -r img; do
121120
case "$img" in
122121
*postgres*) ;; # skip postgres (public Docker Hub image)

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
# ============== VS Code =================
2121
.vscode/
2222

23+
# ============== OpenCode Agents =================
24+
.agents/
25+
.opencode/
26+
openspec/
27+
2328
# ============== Maven / General =================
2429
target/
2530
.mvn/wrapper/maven-wrapper.jar

infra/iac/aet/templates/client/configmap-caddyfile.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,30 @@ metadata:
66
data:
77
Caddyfile: |
88
:80 {
9+
# ── Dev routes (prefix-based, proxies cross-namespace to team-devopss26-dev) ──
10+
handle_path /dev/api/user/* {
11+
reverse_proxy http://user-service.team-devopss26-dev.svc.cluster.local:{{ index .Values.services "user-service" "appPort" }}
12+
}
13+
handle_path /dev/api/admin/* {
14+
reverse_proxy http://admin-service.team-devopss26-dev.svc.cluster.local:{{ index .Values.services "admin-service" "appPort" }}
15+
}
16+
handle_path /dev/api/checklist/* {
17+
reverse_proxy http://checklist-service.team-devopss26-dev.svc.cluster.local:{{ index .Values.services "checklist-service" "appPort" }}
18+
}
19+
handle_path /dev/api/calendar/* {
20+
reverse_proxy http://calendar-service.team-devopss26-dev.svc.cluster.local:{{ index .Values.services "calendar-service" "appPort" }}
21+
}
22+
handle_path /dev/api/note/* {
23+
reverse_proxy http://note-service.team-devopss26-dev.svc.cluster.local:{{ index .Values.services "note-service" "appPort" }}
24+
}
25+
handle_path /dev/api/genai/* {
26+
reverse_proxy http://genai-service.team-devopss26-dev.svc.cluster.local:{{ .Values.genaiService.appPort }}
27+
}
28+
handle_path /dev/* {
29+
reverse_proxy http://client.team-devopss26-dev.svc.cluster.local:80
30+
}
31+
32+
# ── Prod routes ──
933
handle /api/user/* {
1034
reverse_proxy http://user-service:{{ index .Values.services "user-service" "appPort" }}
1135
}

infra/iac/aet/templates/client/deployment.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ spec:
2121
{{- end }}
2222
containers:
2323
- name: client
24-
image: "{{ .Values.client.image.repository }}:{{ .Values.client.image.tag }}"
25-
imagePullPolicy: {{ .Values.client.image.pullPolicy }}
24+
image: "{{ .Values.client.image.repository }}:{{ $.Values.global.imageTag }}"
25+
imagePullPolicy: {{ $.Values.global.imagePullPolicy }}
2626
ports:
2727
- containerPort: {{ .Values.client.port }}
2828
securityContext:
@@ -31,8 +31,8 @@ spec:
3131
add: ["NET_BIND_SERVICE"]
3232
drop: ["ALL"]
3333
resources:
34-
requests: { memory: "64Mi", cpu: "50m" }
35-
limits: { memory: "128Mi", cpu: "200m" }
34+
requests: { memory: "32Mi", cpu: "25m" }
35+
limits: { memory: "64Mi", cpu: "50m" }
3636
volumeMounts:
3737
- name: caddyfile
3838
mountPath: /etc/caddy/Caddyfile

infra/iac/aet/templates/genai-service/configmap.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@ metadata:
44
name: genai-service-config
55
namespace: {{ .Values.global.namespace }}
66
data:
7-
GENAI_SERVICE_APP_PORT: "{{ .Values.genaiService.appPort }}"
7+
GENAI_SERVICE_APP_PORT: "{{ .Values.genaiService.appPort }}"
8+
GENAI_SERVICE_POSTGRES_URL: "postgres"
9+
GENAI_SERVICE_POSTGRES_PORT_INT: "5432"
10+
GENAI_SERVICE_POSTGRES_DB: "{{ .Values.genaiService.dbName }}"
11+
GENAI_SERVICE_POSTGRES_USER: "{{ .Values.postgres.user }}"

infra/iac/aet/templates/genai-service/deployment.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ spec:
2121
{{- end }}
2222
containers:
2323
- name: genai-service
24-
image: "{{ .Values.genaiService.image.repository }}:{{ .Values.genaiService.image.tag }}"
25-
imagePullPolicy: {{ .Values.genaiService.image.pullPolicy }}
24+
image: "{{ .Values.genaiService.image.repository }}:{{ $.Values.global.imageTag }}"
25+
imagePullPolicy: {{ $.Values.global.imagePullPolicy }}
2626
ports:
2727
- containerPort: {{ .Values.genaiService.appPort }}
2828
securityContext:

infra/iac/aet/templates/genai-service/secret.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ metadata:
55
namespace: {{ .Values.global.namespace }}
66
type: Opaque
77
stringData:
8-
GEMINI_API_KEY: "{{ .Values.genaiService.geminiApiKey }}"
8+
GEMINI_API_KEY: "{{ .Values.genaiService.geminiApiKey }}"
9+
GENAI_SERVICE_POSTGRES_PASSWORD: "{{ .Values.postgres.password }}"

infra/iac/aet/templates/namespace.yaml

Lines changed: 0 additions & 4 deletions
This file was deleted.

infra/iac/aet/templates/postgres/statefulset.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ spec:
6969
cpu: "100m"
7070
limits:
7171
memory: "512Mi"
72-
cpu: "500m"
72+
cpu: "200m"
7373
volumes:
7474
- name: init-scripts
7575
configMap:
@@ -109,4 +109,5 @@ data:
109109
CREATE DATABASE admindb;
110110
CREATE DATABASE checklistdb;
111111
CREATE DATABASE calendardb;
112-
CREATE DATABASE notedb;
112+
CREATE DATABASE notedb;
113+
CREATE DATABASE genaidb;

0 commit comments

Comments
 (0)