Zkt22/z2/deployment.yml
2022-05-01 20:50:28 +05:30

114 lines
2.8 KiB
YAML

#
# Backend deployment
#
apiVersion: apps/v1
kind: Deployment
metadata:
name: fruitapp-backend-deployment
namespace: suhailahamed
labels:
app: fruitapp-backend
spec:
replicas: 1
selector:
matchLabels:
app: fruitapp-backend
template:
metadata:
labels:
app: fruitapp-backend
spec:
initContainers:
- name: init-cont
image: busybox:1.31
command: ['sh', '-c',
'echo -e "Checking for the availability of MySQL Server deployment"; while ! nc -z mysql-service 3306; do sleep 1; printf "-"; done; echo -e " >> MySQL DB Server has started";']
containers:
- name: fruitapp-backend
image: fruitapp-backend:latest
imagePullPolicy: IfNotPresent
command: ['bash']
args: ['scripts/entrypoint.sh']
ports:
- containerPort: 5000
env:
- name: SQLALCHEMY_DATABASE_URI
value: mysql://user:password@mysql-service/main
- name: FLASK_APP
value: app.py
- name: MYSQL_DATABASE
value: main
- name: MYSQL_USER
value: user
- name: MYSQL_PASSWORD
value: password
- name: MYSQL_ROOT_PASSWORD
value: root
---
#
# Frontend deployment
#
apiVersion: apps/v1
kind: Deployment
metadata:
name: fruitapp-frontend-deployment
namespace: suhailahamed
labels:
app: fruitapp-frontend
spec:
replicas: 1
selector:
matchLabels:
app: fruitapp-frontend
template:
metadata:
labels:
app: fruitapp-frontend
spec:
containers:
- name: fruitapp-frontend
image: fruitapp-frontend:latest
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
volumeMounts:
- mountPath: /etc/nginx/conf.d/ # mount nginx-conf volumn to /etc/nginx
readOnly: true
name: nginx-conf
volumes:
- name: nginx-conf
configMap:
name: nginx-conf # place ConfigMap `nginx-conf` on /etc/nginx
items:
- key: default.conf
path: default.conf
---
##
## ConfigMap for nginx
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-conf
namespace: suhailahamed
data:
default.conf: |
upstream Backend {
# hello is the internal DNS name used by the backend Service inside Kubernetes
server backend-service:5000;
}
server {
listen 80;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri /index.html;
}
location /api/ {
# The following statement will proxy traffic to the upstream named Backend
proxy_pass http://Backend;
}
}