added k8s files

This commit is contained in:
Kuznetsov Anton 2022-09-01 19:42:24 +06:00
parent 785f178ef6
commit e04555c597
10 changed files with 313 additions and 0 deletions

55
k8s/db-deployment.yaml Normal file
View File

@ -0,0 +1,55 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert -f ../docker-compose.prod.yaml -v
kompose.version: 1.26.1 (a9d05d509)
creationTimestamp: null
labels:
io.kompose.service: db
name: db
spec:
replicas: 1
selector:
matchLabels:
io.kompose.service: db
strategy:
type: Recreate
template:
metadata:
annotations:
kompose.cmd: kompose convert -f ../docker-compose.prod.yaml -v
kompose.version: 1.26.1 (a9d05d509)
creationTimestamp: null
labels:
io.kompose.service: db
spec:
containers:
- env:
- name: POSTGRES_DB
valueFrom:
configMapKeyRef:
key: POSTGRES_DB
name: env-prod-db
- name: POSTGRES_PASSWORD
valueFrom:
configMapKeyRef:
key: POSTGRES_PASSWORD
name: env-prod-db
- name: POSTGRES_USER
valueFrom:
configMapKeyRef:
key: POSTGRES_USER
name: env-prod-db
image: postgres:14.5-alpine
name: db
resources: {}
volumeMounts:
- mountPath: /var/lib/postgresql/data/
name: postgres-data-prod
restartPolicy: Always
volumes:
- name: postgres-data-prod
persistentVolumeClaim:
claimName: postgres-data-prod
status: {}

View File

@ -0,0 +1,19 @@
apiVersion: v1
data:
DATABASE: postgres
DEBUG: "0"
DJANGO_ALLOWED_HOSTS: localhost 127.0.0.1 [::1]
SECRET_KEY: django-insecure-9+
SOME_ENV_VAR: VALUE_OF_SOME_ENV_VAR
SQL_DATABASE: django_prod
SQL_ENGINE: django.db.backends.postgresql
SQL_HOST: db
SQL_PASSWORD: pwddjango
SQL_PORT: "5432"
SQL_USER: django
kind: ConfigMap
metadata:
creationTimestamp: null
labels:
io.kompose.service: web-env-prod
name: env-prod

View File

@ -0,0 +1,11 @@
apiVersion: v1
data:
POSTGRES_DB: django_prod
POSTGRES_PASSWORD: pwddjango
POSTGRES_USER: django
kind: ConfigMap
metadata:
creationTimestamp: null
labels:
io.kompose.service: db-env-prod-db
name: env-prod-db

View File

@ -0,0 +1,14 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: media-volume
name: media-volume
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
status: {}

41
k8s/nginx-deployment.yaml Normal file
View File

@ -0,0 +1,41 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert -f ../docker-compose.prod.yaml -v
kompose.version: 1.26.1 (a9d05d509)
creationTimestamp: null
labels:
io.kompose.service: nginx
name: nginx
spec:
replicas: 1
selector:
matchLabels:
io.kompose.service: nginx
strategy:
type: Recreate
template:
metadata:
annotations:
kompose.cmd: kompose convert -f ../docker-compose.prod.yaml -v
kompose.version: 1.26.1 (a9d05d509)
creationTimestamp: null
labels:
io.kompose.service: nginx
spec:
containers:
- image: nginx
name: nginx
ports:
- containerPort: 80
resources: {}
volumeMounts:
- mountPath: /home/app/staticfiles
name: static-volume
restartPolicy: Always
volumes:
- name: static-volume
persistentVolumeClaim:
claimName: static-volume
status: {}

19
k8s/nginx-service.yaml Normal file
View File

@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
annotations:
kompose.cmd: kompose convert -f ../docker-compose.prod.yaml -v
kompose.version: 1.26.1 (a9d05d509)
creationTimestamp: null
labels:
io.kompose.service: nginx
name: nginx
spec:
ports:
- name: "1337"
port: 1337
targetPort: 80
selector:
io.kompose.service: nginx
status:
loadBalancer: {}

View File

@ -0,0 +1,14 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: postgres-data-prod
name: postgres-data-prod
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
status: {}

View File

@ -0,0 +1,14 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: static-volume
name: static-volume
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
status: {}

107
k8s/web-deployment.yaml Normal file
View File

@ -0,0 +1,107 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert -f ../docker-compose.prod.yaml -v
kompose.version: 1.26.1 (a9d05d509)
creationTimestamp: null
labels:
io.kompose.service: web
name: web
spec:
replicas: 1
selector:
matchLabels:
io.kompose.service: web
strategy:
type: Recreate
template:
metadata:
annotations:
kompose.cmd: kompose convert -f ../docker-compose.prod.yaml -v
kompose.version: 1.26.1 (a9d05d509)
creationTimestamp: null
labels:
io.kompose.service: web
spec:
containers:
- args:
- gunicorn
- example.wsgi:application
- --bind
- 0.0.0.0:8000
env:
- name: DATABASE
valueFrom:
configMapKeyRef:
key: DATABASE
name: env-prod
- name: DEBUG
valueFrom:
configMapKeyRef:
key: DEBUG
name: env-prod
- name: DJANGO_ALLOWED_HOSTS
valueFrom:
configMapKeyRef:
key: DJANGO_ALLOWED_HOSTS
name: env-prod
- name: SECRET_KEY
valueFrom:
configMapKeyRef:
key: SECRET_KEY
name: env-prod
- name: SOME_ENV_VAR
valueFrom:
configMapKeyRef:
key: SOME_ENV_VAR
name: env-prod
- name: SQL_DATABASE
valueFrom:
configMapKeyRef:
key: SQL_DATABASE
name: env-prod
- name: SQL_ENGINE
valueFrom:
configMapKeyRef:
key: SQL_ENGINE
name: env-prod
- name: SQL_HOST
valueFrom:
configMapKeyRef:
key: SQL_HOST
name: env-prod
- name: SQL_PASSWORD
valueFrom:
configMapKeyRef:
key: SQL_PASSWORD
name: env-prod
- name: SQL_PORT
valueFrom:
configMapKeyRef:
key: SQL_PORT
name: env-prod
- name: SQL_USER
valueFrom:
configMapKeyRef:
key: SQL_USER
name: env-prod
image: web
name: web
ports:
- containerPort: 8000
resources: {}
volumeMounts:
- mountPath: /home/app/staticfiles
name: static-volume
- mountPath: /home/app/mediafiles
name: media-volume
restartPolicy: Always
volumes:
- name: static-volume
persistentVolumeClaim:
claimName: static-volume
- name: media-volume
persistentVolumeClaim:
claimName: media-volume
status: {}

19
k8s/web-service.yaml Normal file
View File

@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
annotations:
kompose.cmd: kompose convert -f ../docker-compose.prod.yaml -v
kompose.version: 1.26.1 (a9d05d509)
creationTimestamp: null
labels:
io.kompose.service: web
name: web
spec:
ports:
- name: "8000"
port: 8000
targetPort: 8000
selector:
io.kompose.service: web
status:
loadBalancer: {}