---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: remarks-api
  namespace: remarks
  labels:
    app: remarks-api
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: remarks-api
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: remarks-api
    spec:
      containers:
      - env:
        - name: POSTGRES_ADDRESS
          value: postgres-service
        - name: POSTGRES_PORT
          value: '5432'
        - name: POSTGRES_DB
          value: remarks_db
        - name: POSTGRES_POOL_SIZE
          value: '3'
        - name: API_ADDRESS
          value: 0.0.0.0:8000
        - name: ENABLE_S3_STORAGE
          value: 'true'
        - name: S3_SERVICE_ACCOUNT
          value: /etc/sarex/yc-s3-storage/remarks-yc-s3.json
        - name: DEFAULT_MEDIA_STORAGE
          value: s3
        - name: DEFAULT_MEDIA_PATH
          value: remark-media
        - name: MAX_MEDIA_SIZE_MB
          value: '200'
        - name: DJANGO_HOST
          value: http://backend.django.svc.cluster.local:8000
        - name: NAMESPACE
          value: remarks
        - name: DJANGO_LOGGER_FEATURE
          value: '0'
        - name: DJANGO_ORIGINATOR
          value: rm_prod
        - name: WORKSPACE_URL
          value: http://workspaces-service.workspaces.svc.cluster.local:8000/
        - name: MG_DOMAIN
          value: mg.sarex.io
        - name: MG_SENDER
          value: hello@sarex.io
        - name: WORKER_ADDRESS
          value: 0.0.0.0:8000
        - name: RABBIT_HOST
          value: rabbitmq-service
        - name: RABBIT_PORT
          value: '5672'
        - name: RABBIT_VHOST
          value: remarks-prod
        - name: RABBIT_PING_RETRY_SEC
          value: '10000'
        - name: RABBIT_PING_TIMEOUT_SEC
          value: '10000'
        - name: RABBIT_PING_CTX_TIMEOUT_SEC
          value: '10000'
        - name: TASK_RETRY_COUNT
          value: '3'
        - name: ENABLE_SQL_LOGGING
          value: '0'
        - name: ENABLE_SSL
          value: '0'
        - name: ENVIRONMENT
          value: prod
        - name: POSTGRES_USER
          valueFrom:
            secretKeyRef:
              key: username
              name: postgres-secret
        - name: POSTGRES_PASSWORD
          valueFrom:
            secretKeyRef:
              key: password
              name: postgres-secret
        - name: DJANGO_BASIC_AUTH
          valueFrom:
            secretKeyRef:
              key: key
              name: django-auth
        image: cr.yandex/crp3ccidau046kdj8g9q/remarks-api:6cf9a4aded9fd2711c78f1e5eb28e4a4f823364e
        imagePullPolicy: IfNotPresent
        livenessProbe:
          failureThreshold: 10
          httpGet:
            path: /ping
            port: 8000
            scheme: HTTP
          initialDelaySeconds: 10
          periodSeconds: 60
          successThreshold: 1
          timeoutSeconds: 1
        name: remarks-api
        ports:
        - containerPort: 8000
          name: http
          protocol: TCP
        readinessProbe:
          failureThreshold: 20
          httpGet:
            path: /ping
            port: 8000
            scheme: HTTP
          initialDelaySeconds: 10
          periodSeconds: 30
          successThreshold: 1
          timeoutSeconds: 1
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /etc/sarex/yc-s3-storage
          name: remarks-yc-s3-secret
          readOnly: true
      dnsPolicy: ClusterFirst
      imagePullSecrets:
      - name: dockerhub
      nodeSelector:
        name: generic
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      serviceAccount: remarks-api-sa
      serviceAccountName: remarks-api-sa
      terminationGracePeriodSeconds: 30
      volumes:
      - name: remarks-yc-s3-secret
        secret:
          defaultMode: 420
          secretName: remarks-yc-s3
---
apiVersion: v1
kind: Service
metadata:
  name: remarks-service
  namespace: remarks
  labels:
    app: remarks-api
spec:
  ports:
  - name: http
    port: 8000
    protocol: TCP
    targetPort: 8000
  selector:
    app: remarks-api
  sessionAffinity: None
  type: ClusterIP
