Prepared configuration to deploy to Kubernetes cluster

This commit is contained in:
Marcin-Ramotowski 2025-04-30 10:42:10 +00:00
parent fdd8a56774
commit acf3f75fc7
2 changed files with 159 additions and 0 deletions

139
deploy.yaml Normal file
View File

@ -0,0 +1,139 @@
---
# Namespace (opcjonalnie)
apiVersion: v1
kind: Namespace
metadata:
name: todolist
---
# MySQL Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql
namespace: todolist
spec:
replicas: 1
selector:
matchLabels:
app: mysql
template:
metadata:
labels:
app: mysql
spec:
containers:
- name: mysql
image: mysql:lts
env:
- name: MYSQL_USER
value: guflwhvcmw
- name: MYSQL_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-password
key: MYSQL_PASSWORD
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-root-password
key: MYSQL_ROOT_PASSWORD
- name: MYSQL_DATABASE
value: todolist
ports:
- containerPort: 3306
volumeMounts:
- name: mysql-pv
mountPath: /var/lib/mysql
volumes:
- name: mysql-pv
emptyDir: {}
---
# MySQL Service
apiVersion: v1
kind: Service
metadata:
name: db
namespace: todolist
spec:
ports:
- port: 3306
selector:
app: mysql
---
# API Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: todolist-api
namespace: todolist
spec:
replicas: 1
selector:
matchLabels:
app: todolist-api
template:
metadata:
labels:
app: todolist-api
spec:
containers:
- name: api
image: marcin00.azurecr.io/todolist-api:1.1
ports:
- containerPort: 80
env:
- name: SQLALCHEMY_DATABASE_URI
valueFrom:
secretKeyRef:
name: sqlalchemy-database-uri
key: SQLALCHEMY_DATABASE_URI
---
# API Service
apiVersion: v1
kind: Service
metadata:
name: api
namespace: todolist
spec:
selector:
app: todolist-api
ports:
- port: 80
targetPort: 80
---
# Frontend Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: todolist-frontend
namespace: todolist
spec:
replicas: 1
selector:
matchLabels:
app: todolist-frontend
template:
metadata:
labels:
app: todolist-frontend
spec:
containers:
- name: frontend
image: marcin00.azurecr.io/todolist-frontend:1.1
ports:
- containerPort: 80
---
# Frontend Service
apiVersion: v1
kind: Service
metadata:
name: todolist-frontend
namespace: todolist
spec:
selector:
app: todolist-frontend
ports:
- port: 80
targetPort: 80
protocol: TCP

20
ingress.yaml Normal file
View File

@ -0,0 +1,20 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: todolist-ingress
namespace: todolist
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx
rules:
- host: todolist.marcin00.pl
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: todolist-frontend
port:
number: 80