Add files for deployment of the webapp with Kubernetes
This commit is contained in:
parent
54d6fced76
commit
823b9df176
@ -0,0 +1,52 @@
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
# Deployment – Vert.x Backend (2 replicas)
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: vigimeteo-backend
|
||||
namespace: vigimeteo
|
||||
labels:
|
||||
app: vigimeteo-backend
|
||||
spec:
|
||||
replicas: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
app: vigimeteo-backend
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: vigimeteo-backend
|
||||
spec:
|
||||
initContainers:
|
||||
# Wait until PostgreSQL is ready before starting the backend
|
||||
- name: wait-for-db
|
||||
image: busybox:1.36
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
until nc -z vigimeteo-db.vigimeteo.svc.cluster.local 5432; do
|
||||
echo "Waiting for PostgreSQL...";
|
||||
sleep 3;
|
||||
done;
|
||||
echo "PostgreSQL is ready."
|
||||
containers:
|
||||
- name: vigimeteo-backend
|
||||
image: vigimeteo-backend:latest
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: 8888
|
||||
name: http
|
||||
env:
|
||||
- name: DB_HOST
|
||||
value: "vigimeteo-db.vigimeteo.svc.cluster.local"
|
||||
- name: DB_PORT
|
||||
value: "5432"
|
||||
- name: DB_NAME
|
||||
value: "postgres"
|
||||
- name: DB_USER
|
||||
value: "postgres"
|
||||
- name: DB_PASSWORD
|
||||
value: "admin"
|
||||
|
||||
7
z2/namespace.yaml
Normal file
7
z2/namespace.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: vigimeteo
|
||||
labels:
|
||||
app: vigimeteo
|
||||
environment: production
|
||||
91
z2/service.yaml
Normal file
91
z2/service.yaml
Normal file
@ -0,0 +1,91 @@
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
# Deployment – React/Nginx Frontend (2 replicas)
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: vigimeteo-frontend
|
||||
namespace: vigimeteo
|
||||
labels:
|
||||
app: vigimeteo-frontend
|
||||
spec:
|
||||
replicas: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
app: vigimeteo-frontend
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: vigimeteo-frontend
|
||||
spec:
|
||||
containers:
|
||||
- name: vigimeteo-frontend
|
||||
image: vigimeteo-frontend:latest
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: 80
|
||||
name: http
|
||||
### part bellow recommanded by ia for health check
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 80
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 80
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 15
|
||||
resources:
|
||||
requests:
|
||||
cpu: "50m"
|
||||
memory: "64Mi"
|
||||
limits:
|
||||
cpu: "200m"
|
||||
memory: "128Mi"
|
||||
|
||||
---
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
# Service – Backend ClusterIP (internal access only)
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: vigimeteo-backend-service
|
||||
namespace: vigimeteo
|
||||
labels:
|
||||
app: vigimeteo-backend
|
||||
spec:
|
||||
type: NodePort
|
||||
selector:
|
||||
app: vigimeteo-backend
|
||||
ports:
|
||||
- name: http
|
||||
protocol: TCP
|
||||
port: 8888
|
||||
targetPort: 8888
|
||||
nodePort: 30888
|
||||
|
||||
---
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
# Service – Frontend NodePort (external access via <nodeIP>:30500)
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: vigimeteo-frontend-service
|
||||
namespace: vigimeteo
|
||||
labels:
|
||||
app: vigimeteo-frontend
|
||||
spec:
|
||||
type: NodePort
|
||||
selector:
|
||||
app: vigimeteo-frontend
|
||||
ports:
|
||||
- name: http
|
||||
protocol: TCP
|
||||
port: 80
|
||||
targetPort: 80
|
||||
nodePort: 30500
|
||||
116
z2/statefulset.yaml
Normal file
116
z2/statefulset.yaml
Normal file
@ -0,0 +1,116 @@
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
# PersistentVolume – host-path volume for PostgreSQL data
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
apiVersion: v1
|
||||
kind: PersistentVolume
|
||||
metadata:
|
||||
name: vigimeteo-db-pv
|
||||
namespace: vigimeteo
|
||||
labels:
|
||||
app: vigimeteo-db
|
||||
spec:
|
||||
capacity:
|
||||
storage: 1Gi
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
persistentVolumeReclaimPolicy: Retain
|
||||
storageClassName: manual
|
||||
hostPath:
|
||||
path: /home/cytech/vigimeteo-db-data
|
||||
|
||||
---
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
# PersistentVolumeClaim – claimed by the StatefulSet below
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: vigimeteo-db-pvc
|
||||
namespace: vigimeteo
|
||||
labels:
|
||||
app: vigimeteo-db
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
storageClassName: manual
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Gi
|
||||
|
||||
---
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
# StatefulSet – single PostgreSQL replica
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: vigimeteo-db
|
||||
namespace: vigimeteo
|
||||
labels:
|
||||
app: vigimeteo-db
|
||||
spec:
|
||||
serviceName: vigimeteo-db
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: vigimeteo-db
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: vigimeteo-db
|
||||
spec:
|
||||
containers:
|
||||
- name: postgres
|
||||
image: postgres:17-alpine
|
||||
ports:
|
||||
- containerPort: 5432
|
||||
name: postgres
|
||||
env:
|
||||
- name: POSTGRES_USER
|
||||
value: "postgres"
|
||||
- name: POSTGRES_PASSWORD
|
||||
value: "admin"
|
||||
- name: POSTGRES_DB
|
||||
value: "postgres"
|
||||
volumeMounts:
|
||||
- name: vigimeteo-db-storage
|
||||
mountPath: /var/lib/postgresql/data
|
||||
- name: vigimeteo-db-init
|
||||
mountPath: /docker-entrypoint-initdb.d
|
||||
readinessProbe:
|
||||
exec:
|
||||
command: ["pg_isready", "-U", "postgres"]
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 5
|
||||
livenessProbe:
|
||||
exec:
|
||||
command: ["pg_isready", "-U", "postgres"]
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 10
|
||||
volumes:
|
||||
- name: vigimeteo-db-storage
|
||||
persistentVolumeClaim:
|
||||
claimName: vigimeteo-db-pvc
|
||||
- name: vigimeteo-db-init
|
||||
configMap:
|
||||
name: vigimeteo-db-init
|
||||
|
||||
---
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
# Headless Service – required by the StatefulSet
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: vigimeteo-db
|
||||
namespace: vigimeteo
|
||||
labels:
|
||||
app: vigimeteo-db
|
||||
spec:
|
||||
clusterIP: None # headless – stable DNS name for StatefulSet pods
|
||||
selector:
|
||||
app: vigimeteo-db
|
||||
ports:
|
||||
- name: postgres
|
||||
port: 5432
|
||||
targetPort: 5432
|
||||
Loading…
Reference in New Issue
Block a user