zkt25/z2/deployment.yaml

50 lines
1.1 KiB
YAML

apiVersion: apps/v1
kind: Deployment
metadata:
name: web
namespace: my-app
spec:
replicas: 2
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
initContainers:
- name: wait-for-postgres
image: busybox
command:
- sh
- -c
- |
until nc -z postgres 5432; do
echo "Waiting for PostgreSQL..."
sleep 2
done
containers:
- name: web
image: simple-web-app:latest
imagePullPolicy: IfNotPresent
ports:
- containerPort: 5000
env:
- name: DB_HOST
value: postgres
- name: DB_PORT
value: "5432"
- name: DB_NAME
value: postgres
- name: DB_USER
value: postgres
- name: DB_PASS
value: postgres
readinessProbe:
httpGet:
path: /
port: 5000
initialDelaySeconds: 15
periodSeconds: 10