source: k8s/backend.yaml@ c0086c0

Last change on this file since c0086c0 was c0086c0, checked in by Andrej <asumanovski@…>, 2 weeks ago

Add GitHub Actions CI/CD pipeline with DockerHub and Kubernetes deployment

  • Build job validates both images on every push and PR
  • Push job builds and pushes backend/frontend images to DockerHub on master
  • Deploy job applies k8s manifests and rolls out new images to k3s cluster
  • Added k8s manifests: namespace, postgres StatefulSet, backend and frontend Deployments
  • Added /api/auth/ping health endpoint for k8s readiness/liveness probes
  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[c0086c0]1apiVersion: apps/v1
2kind: Deployment
3metadata:
4 name: backend
5 namespace: trekr
6spec:
7 replicas: 1
8 selector:
9 matchLabels:
10 app: backend
11 template:
12 metadata:
13 labels:
14 app: backend
15 spec:
16 initContainers:
17 - name: wait-for-postgres
18 image: postgres:16-alpine
19 command: [sh, -c, until pg_isready -h postgres -p 5432 -U trekr; do sleep 2; done]
20 containers:
21 - name: backend
22 image: trekr-backend:latest # overwritten by pipeline via kubectl set image
23 env:
24 - name: SPRING_DATASOURCE_URL
25 value: jdbc:postgresql://postgres:5432/trekr
26 - name: SPRING_DATASOURCE_USERNAME
27 value: trekr
28 - name: SPRING_DATASOURCE_PASSWORD
29 valueFrom:
30 secretKeyRef:
31 name: trekr-secrets
32 key: db-password
33 - name: SPRING_JPA_HIBERNATE_DDL_AUTO
34 value: none
35 - name: JWT_SECRET
36 valueFrom:
37 secretKeyRef:
38 name: trekr-secrets
39 key: jwt-secret
40 ports:
41 - containerPort: 8080
42 readinessProbe:
43 httpGet:
44 path: /api/auth/ping
45 port: 8080
46 initialDelaySeconds: 20
47 periodSeconds: 10
48 failureThreshold: 6
49 livenessProbe:
50 httpGet:
51 path: /api/auth/ping
52 port: 8080
53 initialDelaySeconds: 60
54 periodSeconds: 15
55---
56apiVersion: v1
57kind: Service
58metadata:
59 name: backend
60 namespace: trekr
61spec:
62 selector:
63 app: backend
64 ports:
65 - port: 8080
66 targetPort: 8080
Note: See TracBrowser for help on using the repository browser.