iac/rmk/apps/resources/deployment-backend.yaml
2026-11-17 19:12:41 +03:00

115 lines
3.7 KiB
YAML

apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: backend
name: backend
namespace: resources
spec:
replicas: 1
selector:
matchLabels:
app: backend
template:
metadata:
annotations:
traffic.sidecar.istio.io/excludeOutboundPorts: '8200'
vault.hashicorp.com/agent-init-first: 'true'
vault.hashicorp.com/agent-inject: 'true'
vault.hashicorp.com/agent-inject-secret-resources-db: secrets/data/apps/resources/postgres
vault.hashicorp.com/agent-inject-secret-resources-s3: secrets/data/minio/apps/resources
vault.hashicorp.com/agent-inject-template-resources-db: |-
{{- with secret "secrets/data/apps/resources/postgres" -}}
DATABASE_HOST={{ index .Data.data "host" }}
DATABASE_PORT={{ index .Data.data "port" }}
DATABASE_NAME={{ index .Data.data "database" }}
DATABASE_USER={{ index .Data.data "username" }}
DATABASE_PASSWORD={{ index .Data.data "password" }}
{{- end -}}
vault.hashicorp.com/agent-inject-template-resources-s3: |-
{{- with secret "secrets/data/minio/apps/resources" -}}
YC_S3_ENDPOINT_URL={{ with index .Data.data "client" }}{{ index . "endpoint" }}{{ else }}{{ index .Data.data "endpoint" }}{{ end }}
YC_S3_BUCKET_NAME=resources
YC_S3_ACCESS_KEY_ID={{ or (index .Data.data "access_key") (index .Data.data "access_key_id") }}
YC_S3_SECRET_ACCESS_KEY={{ or (index .Data.data "secret_key") (index .Data.data "secret_access_key") }}
{{- end -}}
vault.hashicorp.com/agent-pre-populate-only: 'true'
vault.hashicorp.com/auth-path: auth/kubernetes
vault.hashicorp.com/role: resources
labels:
app: backend
spec:
nodeSelector:
dedicated: backend
tolerations:
- key: dedicated
operator: Equal
value: backend
effect: NoSchedule
containers:
- args:
- |
set -a
[ -f /vault/secrets/resources-db ] && . /vault/secrets/resources-db
[ -f /vault/secrets/resources-s3 ] && . /vault/secrets/resources-s3
set +a
exec /server/entrypoint.sh
command:
- /bin/sh
- -ec
env:
- name: DJANGO_SETTINGS_MODULE
value: config.settings.production
- name: API_ADDRESS
value: '8000'
image: cr.yandex/crp3ccidau046kdj8g9q/sarex-resources:latest
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 5
initialDelaySeconds: 20
periodSeconds: 30
tcpSocket:
port: 8000
timeoutSeconds: 3
name: backend
ports:
- containerPort: 8000
name: http
protocol: TCP
readinessProbe:
failureThreshold: 6
initialDelaySeconds: 10
periodSeconds: 10
tcpSocket:
port: 8000
timeoutSeconds: 3
resources:
requests:
cpu: 25m
memory: 100Mi
volumeMounts:
- mountPath: /server/config/settings/production.py
name: django-configmap
subPath: production.py
- mountPath: opt/server/uwsgi.ini
name: uwsgi-configmap
subPath: uwsgi.ini
imagePullSecrets:
- name: regcred
serviceAccountName: resources-vault
volumes:
- configMap:
items:
- key: production.py
path: production.py
name: django-configmap
defaultMode: 420
name: django-configmap
- configMap:
defaultMode: 420
items:
- key: uwsgi.ini
path: uwsgi.ini
name: uwsgi-configmap
name: uwsgi-configmap