---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: bim-api
  namespace: bim
  labels:
    app: bim-api
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: bim-api
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: bim-api
    spec:
      containers:
      - command:
        - ./entrypoint_api.sh
        env:
        - name: JWT_PUBLIC_KEY_PATH
          value: /etc/sarex/keys/prod.rsa.pub
        - name: FEATURE_ENABLE_JWT_AUTH
          value: 'false'
        - name: FEATURE_ENABLE_SAREX_AUTH
          value: 'false'
        - name: FEATURE_ENABLE_WORKSPACES
          value: 'true'
        - name: FEATURE_ENABLE_GCLOUD
          value: 'false'
        - name: FEATURE_ENABLE_S3
          value: 'true'
        - name: S3_BUCKET
          value: sarex-bim-storage
        - name: BIM_CURRENT_STORAGE
          value: s3
        - name: AWS_DEFAULT_REGION
          value: ru-central1
        - name: FEATURE_ENABLE_PROCESSING
          value: '1'
        - name: PROCESSING_API_URL
          value: http://workflows-service.processing.svc.cluster.local:8000/internal
        - name: PROCESSING_C2M_VERSION
          value: stable
        - name: prometheus_multiproc_dir
          value: /tmp
        - name: GOOGLE_APPLICATION_CREDENTIALS
          value: /etc/sarex/google-storage/service_account.json
        - name: BUNDLE_VERSION
          value: v1
        - name: WORKSPACES_API_URL
          value: http://workspaces-service.workspaces.svc.cluster.local:8000/internal
        - name: BIM_API_EXTERNAL_HOST_SCHEMA
          value: https
        - name: BIM_API_EXTERNAL_HOST
          value: sarex.uralchem.com
        - name: BIM_API_INTERNAL_HOST_SCHEMA
          value: http
        - name: BIM_API_INTERNAL_HOST
          value: bim-api-service.bim.svc.cluster.local:5555
        - name: DB_HOST
          value: postgres-service-bim-v1
        - name: DB_PORT
          value: '5432'
        - name: MESH_OPTIMIZER_PATH
          value: gltfpack
        - name: DEBUG
          value: '0'
        - name: STORAGE_SEGMENT
          value: sarex-production-storage
        - name: STORAGE_PROJECT
          value: sarex-production
        - name: TMP_DIR
          value: /tmp
        - name: WEBHOOK_URL
          value: http://bim-api-service.bim.svc.cluster.local:5555
        - name: COMPARATOR_API_URL
          value: http://comparator-api-service.comparator-prod/internal
        - name: RABBIT_VHOST
          value: api
        - name: RABBIT_HOST
          value: rabbitmq-service.rabbitmq:5672
        - name: DISABLE_INSTANCING
          value: '0'
        - name: DB_USER
          valueFrom:
            secretKeyRef:
              key: username
              name: postgres-secret-bim-v1
        - name: DB_PASSWORD
          valueFrom:
            secretKeyRef:
              key: password
              name: postgres-secret-bim-v1
        - name: RABBIT_USER
          valueFrom:
            secretKeyRef:
              key: username
              name: rabbitmq-secret
        - name: RABBIT_PASSWORD
          valueFrom:
            secretKeyRef:
              key: password
              name: rabbitmq-secret
        - name: AWS_ACCESS_KEY_ID
          valueFrom:
            secretKeyRef:
              key: key-id
              name: s3-cred
        - name: AWS_SECRET_ACCESS_KEY
          valueFrom:
            secretKeyRef:
              key: access-key
              name: s3-cred
        image: cr.yandex/crp3ccidau046kdj8g9q/bim-api:870965d1967cd761965029b0480884ab7fa7c951
        imagePullPolicy: IfNotPresent
        name: bim-api
        ports:
        - containerPort: 5555
          name: http
          protocol: TCP
        - containerPort: 9000
          name: prom
          protocol: TCP
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /tmp
          name: tmp-volume
      dnsPolicy: ClusterFirst
      imagePullSecrets:
      - name: dockerhub
      nodeSelector:
        name: generic
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      serviceAccount: bim-api-sa
      serviceAccountName: bim-api-sa
      terminationGracePeriodSeconds: 30
      volumes:
      - emptyDir: {}
        name: tmp-volume
---
apiVersion: v1
kind: Service
metadata:
  name: bim-api-service
  namespace: bim
  labels: {}
spec:
  externalTrafficPolicy: Cluster
  ports:
  - name: http
    nodePort: 31352
    port: 5555
    protocol: TCP
    targetPort: 5555
  selector:
    app: bim-api
  sessionAffinity: None
  type: NodePort
