From 842e117365f753ef4fedd43948f5194bd55401f2 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 19 Nov 2026 12:53:07 +0500 Subject: [PATCH] brusnika-stage: deploy premises API with ephemeral PostgreSQL --- apps/premises/brusnika-stage/backend.yaml | 102 ++++++++++++++++++ .../brusnika-stage/kustomization.yaml | 7 ++ apps/premises/brusnika-stage/postgresql.yaml | 57 ++++++++++ apps/premises/brusnika-stage/service.yaml | 12 +++ clusters/brusnika-stage/kustomization.yaml | 3 +- .../brusnika-stage/istio-config.yaml | 12 +++ 6 files changed, 192 insertions(+), 1 deletion(-) create mode 100644 apps/premises/brusnika-stage/backend.yaml create mode 100644 apps/premises/brusnika-stage/kustomization.yaml create mode 100644 apps/premises/brusnika-stage/postgresql.yaml create mode 100644 apps/premises/brusnika-stage/service.yaml diff --git a/apps/premises/brusnika-stage/backend.yaml b/apps/premises/brusnika-stage/backend.yaml new file mode 100644 index 0000000..722f470 --- /dev/null +++ b/apps/premises/brusnika-stage/backend.yaml @@ -0,0 +1,102 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: premises-backend + namespace: premises +spec: + replicas: 1 + selector: + matchLabels: + app: premises-backend + template: + metadata: + labels: + app: premises-backend + spec: + imagePullSecrets: + - name: regcred + initContainers: + - name: wait-postgres + image: postgres:16 + command: + - sh + - -ec + - until pg_isready -h postgres -p 5432; do sleep 2; done + containers: + - name: backend + image: cr.yandex/crp3ccidau046kdj8g9q/premises-backend:production_216148a9 + ports: + - name: http + containerPort: 8000 + env: + - name: DEBUG + value: 'false' + - name: HTTP_ROOT_PATH + value: /premises + - name: JWT_AUTH_ENABLE + value: 'true' + - name: GUNICORN_WORKERS + value: '2' + - name: FASTSTREAM_WORKERS + value: '3' + - name: DATABASE_POOL_SIZE + value: '5' + - name: KAFKA_EAV_ASSET_TOPIC_NAME + value: assets_broadcast + - name: KAFKA_SSL_CERT + value: '' + - name: S3_BUCKET + value: premises + - name: EXPORT_TTL_MINUTES + value: '30' + - name: EXPORT_MAX_WORKERS + value: '4' + - name: EXPORT_S3_KEY_PREFIX + value: premise-export + - name: ATTACHMENT_MAX_SIZE_BYTES + value: '314572800' + - name: ATTACHMENT_S3_KEY_PREFIX + value: attachment/ + - name: OTEL_ENABLE + value: 'false' + - name: OTEL_URL + value: http://signoz-otel-collector-external.signoz.svc.cluster.local:4317 + - name: OTEL_SERVICE_NAME + value: premises-backend + - name: OTEL_INSECURE + value: 'true' + - name: SRX_SDK_IAM_ENVIRONMENT + value: stage + - name: WORKFLOWS_HOST + value: http://workflows-api-service.workflow.svc.cluster.local:8000 + - name: WORKFLOWS_GENERATION_IMAGE + value: cr.yandex/crp3ccidau046kdj8g9q/rendering-template:master + - name: WORKFLOWS_DOCX_TO_PDF_IMAGE + value: cr.yandex/crp3ccidau046kdj8g9q/docx-to-pdf:latest + - name: WORKFLOWS_CALLBACK_IMAGE + value: cr.yandex/crp3ccidau046kdj8g9q/webhook-caller:master + - name: WORKFLOWS_CALLBACK_HOST + value: http://backend-svc.premises.svc.cluster.local:80 + - name: WORKFLOWS_RESULT_PATH + value: premises-stage + - name: SRX_SDK_IAM_ROUTE + value: http://iam-backend.iam.svc.cluster.local:8000 + envFrom: + - secretRef: + name: premises-config + resources: + requests: + cpu: 100m + memory: 256Mi + readinessProbe: + httpGet: + path: /internal/healthz/ready/ + port: http + initialDelaySeconds: 10 + periodSeconds: 10 + livenessProbe: + httpGet: + path: /internal/healthz/live/ + port: http + initialDelaySeconds: 60 + periodSeconds: 30 diff --git a/apps/premises/brusnika-stage/kustomization.yaml b/apps/premises/brusnika-stage/kustomization.yaml new file mode 100644 index 0000000..7eb5002 --- /dev/null +++ b/apps/premises/brusnika-stage/kustomization.yaml @@ -0,0 +1,7 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: premises +resources: +- backend.yaml +- service.yaml +- postgresql.yaml diff --git a/apps/premises/brusnika-stage/postgresql.yaml b/apps/premises/brusnika-stage/postgresql.yaml new file mode 100644 index 0000000..f40eee8 --- /dev/null +++ b/apps/premises/brusnika-stage/postgresql.yaml @@ -0,0 +1,57 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: postgres + namespace: premises +spec: + replicas: 1 + strategy: + type: Recreate + selector: + matchLabels: + app: premises-postgres + template: + metadata: + labels: + app: premises-postgres + spec: + containers: + - name: postgres + image: postgres:16 + ports: + - name: postgres + containerPort: 5432 + envFrom: + - secretRef: + name: postgres-secret + volumeMounts: + - name: data + mountPath: /var/lib/postgresql/data + resources: + requests: + cpu: 100m + memory: 128Mi + readinessProbe: + exec: + command: + - sh + - -ec + - pg_isready -U "$POSTGRES_USER" -d "$POSTGRES_DB" + initialDelaySeconds: 5 + periodSeconds: 5 + volumes: + - name: data + emptyDir: {} +--- +apiVersion: v1 +kind: Service +metadata: + name: postgres + namespace: premises +spec: + selector: + app: premises-postgres + ports: + - name: postgres + port: 5432 + targetPort: postgres diff --git a/apps/premises/brusnika-stage/service.yaml b/apps/premises/brusnika-stage/service.yaml new file mode 100644 index 0000000..b9a8fa5 --- /dev/null +++ b/apps/premises/brusnika-stage/service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: backend-svc + namespace: premises +spec: + selector: + app: premises-backend + ports: + - name: http + port: 80 + targetPort: http diff --git a/clusters/brusnika-stage/kustomization.yaml b/clusters/brusnika-stage/kustomization.yaml index 26387e0..91b3aee 100644 --- a/clusters/brusnika-stage/kustomization.yaml +++ b/clusters/brusnika-stage/kustomization.yaml @@ -37,4 +37,5 @@ resources: - ../../apps/ams-sync/brusnika-stage - ../../apps/iam/brusnika-stage - ../../apps/auth-flow/brusnika-stage - - ../../apps/bi/brusnika-stage \ No newline at end of file + - ../../apps/bi/brusnika-stage + - ../../apps/premises/brusnika-stage diff --git a/infrastructure/istio-config/brusnika-stage/istio-config.yaml b/infrastructure/istio-config/brusnika-stage/istio-config.yaml index 1377a11..cfdfa8f 100644 --- a/infrastructure/istio-config/brusnika-stage/istio-config.yaml +++ b/infrastructure/istio-config/brusnika-stage/istio-config.yaml @@ -532,6 +532,18 @@ spec: prefix: /res-admin/ service: resources-service.resources.svc.cluster.local port: 8000 + vs-premises-api: + namespace: ingress-nginx + hosts: + - test.sarex.brusnika.tech + gateways: + - ingress-nginx/main-gateway + routes: + - path: + prefix: /premises/api/ + rewrite: /api/ + service: backend-svc.premises.svc.cluster.local + port: 80 inspections-vs: namespace: inspections hosts: