Skip to content

Commit c10d764

Browse files
committed
feat(k8s): deploy backend en kind cluster
1 parent eb6e39e commit c10d764

5 files changed

Lines changed: 63 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: backend
5+
labels:
6+
app: backend
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
app: backend
12+
template:
13+
metadata:
14+
labels:
15+
app: backend
16+
spec:
17+
containers:
18+
- name: backend
19+
image: devops-portfolio-fastapi-backend:latest
20+
imagePullPolicy: IfNotPresent
21+
ports:
22+
- containerPort: 8000
23+
env:
24+
- name: PORT
25+
value: "8000"
26+
envFrom:
27+
- configMapRef:
28+
name: backend-config
29+
- secretRef:
30+
name: backend-secret
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: backend-config
5+
data:
6+
PROJECT_NAME: "DevOps Portfolio FastAPI"
7+
POSTGRES_SERVER: "db"
8+
POSTGRES_USER: "postgres"
9+
BACKEND_CORS_ORIGINS: '["http://localhost:5173","http://localhost:30080","http://localhost:8000"]'
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: backend-secret
5+
type: Opaque
6+
stringData:
7+
FIRST_SUPERUSER: "admin@example.com"
8+
FIRST_SUPERUSER_PASSWORD: "admin123"

k8s/portfolio/backend/service.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: backend
5+
spec:
6+
type: NodePort
7+
selector:
8+
app: backend
9+
ports:
10+
- port: 8000
11+
targetPort: 8000
12+
nodePort: 30080

kind-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
kind: Cluster
2+
apiVersion: kind.x-k8s.io/v1alpha4
3+
nodes:
4+
- role: control-plane

0 commit comments

Comments
 (0)