apiVersion: apps/v1
kind: Deployment
metadata:
  name: api
  namespace: production
spec:
  selector:
    matchLabels:
      app: api
  replicas: 2
  template:
    metadata:
      labels:
        app: api
    spec:
      containers:
      - name: ori-api
        image: ontola/ori_api:shallow_nesting
        imagePullPolicy: Always
        env:
        - name: API_DIR
          value: /var/opt/ori_data/id/api/v1
        - name: KAFKA_HOSTNAME
          valueFrom:
            configMapKeyRef:
              key: KAFKA_HOST
              name: config
        - name: THREAD_COUNT
          value: "6"
        - name: KAFKA_ADDRESS
          valueFrom:
            configMapKeyRef:
              key: KAFKA_ADDRESS
              name: config
        - name: DELTA_TOPIC
          valueFrom:
            configMapKeyRef:
              key: KAFKA_TOPIC
              name: config
        - name: KAFKA_USERNAME
          valueFrom:
            secretKeyRef:
              key: KAFKA_USERNAME
              name: secrets
        - name: KAFKA_PASSWORD
          valueFrom:
            secretKeyRef:
              key: KAFKA_PASSWORD
              name: secrets
        - name: REDIS_ADDRESS
          value: redis://redis:6379
        - name: BUGSNAG_KEY
          value: f74b79ff1f813488777566c864845056
        volumeMounts:
        - mountPath: /var/opt/ori_data/id
          name: api-pvc
        resources:
          requests:
            memory: 450M
            cpu: 200m
          limits:
            memory: 800M
            cpu: 500m
      volumes:
      - name: api-pvc
        persistentVolumeClaim:
          claimName: ori-api-pvc
      affinity:
        podAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app
                operator: In
                values:
                - api-serve
            topologyKey: kubernetes.io/hostname