---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: gnomad-api
  labels:
    component: gnomad-api
spec:
  replicas: 1
  selector:
    matchLabels:
      name: gnomad-api
  template:
    metadata:
      labels:
        name: gnomad-api
    spec:
      containers:
        - name: app
          image: gnomad-api
          env:
            - name: PORT
              value: '8000'
            - name: ELASTICSEARCH_URL
              value: http://gnomad-es-http:9200  # FIXME: This depends on using "gnomad" as the ES cluster name
            - name: ELASTICSEARCH_USERNAME
              value: elastic
            - name: ELASTICSEARCH_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: gnomad-es-elastic-user  # FIXME: This depends on using "gnomad" as the ES cluster name
                  key: elastic
            - name: CACHE_REDIS_URL
              value: redis://redis:6379/1
            - name: RATE_LIMITER_REDIS_URL
              value: redis://redis:6379/2
            - name: TRUST_PROXY
              valueFrom:
                configMapKeyRef:
                  name: proxy-ips
                  key: ips
            # Global rate limiting
            - name: MAX_CONCURRENT_ES_REQUESTS
              value: '10'
            - name: MAX_QUEUED_ES_REQUESTS
              value: '100'
            # Individual rate limiting
            - name: MAX_REQUESTS_PER_MINUTE
              value: '30'
            - name: MAX_QUERY_COST
              value: '25'
            - name: MAX_QUERY_COST_PER_MINUTE
              value: '300'
          ports:
            - name: http
              containerPort: 8000
          resources:
            requests:
              cpu: '1'
              memory: '2Gi'
            limits:
              cpu: '2'
              memory: '4Gi'
          readinessProbe:
            httpGet:
              path: /health/ready
              port: http
            initialDelaySeconds: 3
            periodSeconds: 10
      nodeSelector:
        cloud.google.com/gke-nodepool: 'default-pool'
