Add K8s deployment files, restructure to backend/frontend
This commit is contained in:
158
k8s/backend/deployment.yaml
Normal file
158
k8s/backend/deployment.yaml
Normal file
@@ -0,0 +1,158 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: todo-backend
|
||||
labels:
|
||||
app: todo-backend
|
||||
spec:
|
||||
replicas: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
app: todo-backend
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: todo-backend
|
||||
spec:
|
||||
containers:
|
||||
- name: todo-backend
|
||||
image: todo-backend:latest
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
env:
|
||||
- name: SPRING_DATASOURCE_URL
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: todo-config
|
||||
key: DATABASE_URL
|
||||
- name: SPRING_DATASOURCE_USERNAME
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: todo-config
|
||||
key: DATABASE_USERNAME
|
||||
- name: SPRING_DATASOURCE_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: todo-secret
|
||||
key: DATABASE_PASSWORD
|
||||
- name: SPRING_REDIS_HOST
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: todo-config
|
||||
key: REDIS_HOST
|
||||
- name: SPRING_REDIS_PORT
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: todo-config
|
||||
key: REDIS_PORT
|
||||
resources:
|
||||
requests:
|
||||
memory: "512Mi"
|
||||
cpu: "250m"
|
||||
limits:
|
||||
memory: "1Gi"
|
||||
cpu: "500m"
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /actuator/health
|
||||
port: 8080
|
||||
initialDelaySeconds: 60
|
||||
periodSeconds: 10
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /actuator/health
|
||||
port: 8080
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 5
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: todo-postgres
|
||||
labels:
|
||||
app: todo-postgres
|
||||
spec:
|
||||
serviceName: todo-postgres
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: todo-postgres
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: todo-postgres
|
||||
spec:
|
||||
containers:
|
||||
- name: postgres
|
||||
image: postgres:15-alpine
|
||||
ports:
|
||||
- containerPort: 5432
|
||||
env:
|
||||
- name: POSTGRES_DB
|
||||
value: building_materials
|
||||
- name: POSTGRES_USER
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: todo-config
|
||||
key: DATABASE_USERNAME
|
||||
- name: POSTGRES_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: todo-secret
|
||||
key: DATABASE_PASSWORD
|
||||
volumeMounts:
|
||||
- name: postgres-data
|
||||
mountPath: /var/lib/postgresql/data
|
||||
- name: init-sql
|
||||
mountPath: /docker-entrypoint-initdb.d
|
||||
resources:
|
||||
requests:
|
||||
memory: "256Mi"
|
||||
cpu: "100m"
|
||||
limits:
|
||||
memory: "512Mi"
|
||||
cpu: "500m"
|
||||
volumes:
|
||||
- name: postgres-data
|
||||
emptyDir: {}
|
||||
- name: init-sql
|
||||
configMap:
|
||||
name: todo-init-sql
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: todo-redis
|
||||
labels:
|
||||
app: todo-redis
|
||||
spec:
|
||||
serviceName: todo-redis
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: todo-redis
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: todo-redis
|
||||
spec:
|
||||
containers:
|
||||
- name: redis
|
||||
image: redis:7-alpine
|
||||
ports:
|
||||
- containerPort: 6379
|
||||
command: ["redis-server", "--requirepass", ""]
|
||||
resources:
|
||||
requests:
|
||||
memory: "128Mi"
|
||||
cpu: "50m"
|
||||
limits:
|
||||
memory: "256Mi"
|
||||
cpu: "200m"
|
||||
volumeMounts:
|
||||
- name: redis-data
|
||||
mountPath: /data
|
||||
volumes:
|
||||
- name: redis-data
|
||||
emptyDir: {}
|
||||
Reference in New Issue
Block a user