177 lines
5.9 KiB
YAML
177 lines
5.9 KiB
YAML
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: sarex-inspections
|
|
namespace: inspections
|
|
labels:
|
|
app: sarex-inspections
|
|
spec:
|
|
progressDeadlineSeconds: 600
|
|
replicas: 0
|
|
revisionHistoryLimit: 10
|
|
selector:
|
|
matchLabels:
|
|
app: sarex-inspections
|
|
strategy:
|
|
rollingUpdate:
|
|
maxSurge: 25%
|
|
maxUnavailable: 25%
|
|
type: RollingUpdate
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: sarex-inspections
|
|
spec:
|
|
containers:
|
|
- env:
|
|
- name: POSTGRES_HOST
|
|
value: postgres-service.inspections.svc.cluster.local
|
|
- name: POSTGRES_PORT
|
|
value: '5432'
|
|
- name: DATABASE_NAME
|
|
value: inspections_db
|
|
- name: API_ADDRESS
|
|
value: '8000'
|
|
- name: ENVIRONMENT
|
|
value: production
|
|
- name: DJANGO_BASIC_AUTH
|
|
valueFrom:
|
|
secretKeyRef:
|
|
key: key
|
|
name: django-auth
|
|
- name: POSTGRES_USER
|
|
valueFrom:
|
|
secretKeyRef:
|
|
key: user
|
|
name: postgres-secret
|
|
- name: POSTGRES_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
key: password
|
|
name: postgres-secret
|
|
- name: YC_S3_ACCESS_KEY_ID
|
|
valueFrom:
|
|
secretKeyRef:
|
|
key: key_id
|
|
name: yc-s3-secret
|
|
- name: YC_S3_SECRET_ACCESS_KEY
|
|
valueFrom:
|
|
secretKeyRef:
|
|
key: access_key
|
|
name: yc-s3-secret
|
|
- name: YC_S3_BUCKET_NAME
|
|
valueFrom:
|
|
secretKeyRef:
|
|
key: storage_bucket_name
|
|
name: yc-s3-secret
|
|
- name: YC_S3_ENDPOINT_URL
|
|
valueFrom:
|
|
secretKeyRef:
|
|
key: endpoint_url
|
|
name: yc-s3-secret
|
|
image: cr.yandex/crp3ccidau046kdj8g9q/sarex-inspections:2a5866e77fd42d62735401ae8301d492c65ef383
|
|
imagePullPolicy: IfNotPresent
|
|
name: sarex-inspections
|
|
ports:
|
|
- containerPort: 8000
|
|
name: http
|
|
protocol: TCP
|
|
resources:
|
|
requests:
|
|
cpu: '1'
|
|
memory: 512Mi
|
|
terminationMessagePath: /dev/termination-log
|
|
terminationMessagePolicy: File
|
|
volumeMounts:
|
|
- mountPath: /opt/server/uwsgi.ini
|
|
name: uwsgi-configmap
|
|
subPath: uwsgi.ini
|
|
- mountPath: /server/config/settings/production.py
|
|
name: django-configmap
|
|
subPath: production.py
|
|
dnsPolicy: ClusterFirst
|
|
imagePullSecrets:
|
|
- name: dockerhub
|
|
nodeSelector:
|
|
name: generic
|
|
restartPolicy: Always
|
|
schedulerName: default-scheduler
|
|
securityContext: {}
|
|
terminationGracePeriodSeconds: 30
|
|
volumes:
|
|
- configMap:
|
|
defaultMode: 420
|
|
items:
|
|
- key: uwsgi.ini
|
|
path: uwsgi.ini
|
|
name: uwsgi-configmap
|
|
name: uwsgi-configmap
|
|
- configMap:
|
|
defaultMode: 420
|
|
items:
|
|
- key: production.py
|
|
path: production.py
|
|
name: django-configmap
|
|
name: django-configmap
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: inspections-service
|
|
namespace: inspections
|
|
labels: {}
|
|
spec:
|
|
ports:
|
|
- port: 80
|
|
protocol: TCP
|
|
targetPort: 8000
|
|
selector:
|
|
app: sarex-inspections
|
|
sessionAffinity: None
|
|
type: ClusterIP
|
|
---
|
|
apiVersion: v1
|
|
data:
|
|
production.py: "import os\n\nfrom .base import * # noqa: F401, F403\n\n# Base settings\nDEBUG = True\nALLOWED_HOSTS = [\n \"localhost\",\n \"sarex.dsinv.ru\",\n \"inspections-service.inspections\",\n \"sarex-inspections-service.inspections-prod\",\n]\n\n\n# REST framework settings\nREST_FRAMEWORK = {\n \"DEFAULT_FILTER_BACKENDS\": [\n \"django_filters.rest_framework.DjangoFilterBackend\",\n ],\n \"DEFAULT_RENDERER_CLASSES\": [\n \"rest_framework.renderers.JSONRenderer\",\n ],\n \"DEFAULT_PAGINATION_CLASS\": \"rest_framework.pagination.LimitOffsetPagination\",\n \"PAGE_SIZE\": 100,\n}\n\n\n# Database settings\nDATABASES = {\n \"default\": {\n \"ENGINE\": \"core.db.backends.postgis\",\n \"NAME\": os.getenv(\"POSTGRES_DB\") or \"postgres\",\n \"HOST\": os.getenv(\"POSTGRES_HOST\") or \"postgres\",\n \"PORT\": os.getenv(\"POSTGRES_PORT\") or \"5432\",\n \"USER\": os.getenv(\"POSTGRES_USER\") or \"postgres\",\n \"PASSWORD\": os.getenv(\"POSTGRES_PASSWORD\") or \"postgres\",\n }\n}\n\n\n# CORS settings\nCORS_ALLOWED_ORIGINS = [\n \"https://localhost.8000\",\n \"https://localhost.8080\",\n \"https://stage.sarex.io\",\n \"https://sarex.dsinv.ru\",\n \"https://api.sarex.io\",\n \"https://lk.sarex.io\",\n]\nCORS_ALLOW_ALL_ORIGINS = True\nCORS_ALLOW_METHODS = [\n \"GET\",\n \"OPTIONS\",\n \"POST\",\n \"PUT\",\n \"PATCH\",\n \"DELETE\",\n]\n\n\n# S3 settings\nAWS_S3_ENDPOINT_URL = os.getenv(\"YC_S3_ENDPOINT_URL\")\nAWS_STORAGE_BUCKET_NAME = os.getenv(\"YC_S3_BUCKET_NAME\")\nAWS_ACCESS_KEY_ID = os.getenv(\"YC_S3_ACCESS_KEY_ID\")\nAWS_SECRET_ACCESS_KEY = os.getenv(\"YC_S3_SECRET_ACCESS_KEY\")\nAWS_DEFAULT_ACL = \"public-read\"\n\nif AWS_S3_ENDPOINT_URL and AWS_STORAGE_BUCKET_NAME and AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY:\n STATICFILES_STORAGE = \"storages.backends.s3boto3.S3Boto3Storage\"\n DEFAULT_FILE_STORAGE = \"storages.backends.s3boto3.S3Boto3Storage\"\n"
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: django-configmap
|
|
namespace: inspections
|
|
---
|
|
apiVersion: v1
|
|
data:
|
|
uwsgi.ini: '[uwsgi]
|
|
|
|
|
|
chdir = /server
|
|
|
|
module = config.wsgi:application
|
|
|
|
master = true
|
|
|
|
master-fifo = /opt/server/uwsgi-backend-server.fifo
|
|
|
|
processes = 8
|
|
|
|
http = 0.0.0.0:8000
|
|
|
|
chmod-socket = 666
|
|
|
|
vacuum = true
|
|
|
|
harakiri = 6000
|
|
|
|
buffer-size = 32768
|
|
|
|
|
|
static-map = /static=/opt/server/static/
|
|
|
|
static-map = /media=/opt/server/media/
|
|
|
|
'
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: uwsgi-configmap
|
|
namespace: inspections
|