apiVersion: apps/v1
kind: Deployment
metadata:
  name: api
  labels:
    app: api
spec:
  replicas: 3
  selector:
    matchLabels:
      app: api
  strategy:
    rollingUpdate:
      maxSurge: 0
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: api
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app
                operator: In
                values:
                - api
            topologyKey: kubernetes.io/hostname
      containers:
      - name: api
        command: ["gunicorn", "--conf", "gunicorn.conf.py", "maps.app:app"]
        env:
        - name: GUNICORN_ACCESSLOG
          value: "-"
        - name: GUNICORN_BIND
          value: 0.0.0.0:8080
        - name: GUNICORN_CAPTURE_OUTPUT
          value: "true"
        - name: GUNICORN_ERRORLOG
          value: "-"
        - name: GUNICORN_LOGLEVEL
          value: debug
        - name: GUNICORN_RELOAD
          value: "true"
        - name: GUNICORN_WORKERS
          value: "4"
        - name: GUNICORN_WORKER_CLASS
          value: aiohttp.worker.GunicornUVLoopWebWorker
        - name: GUNICORN_ENABLE_STDIO_INHERITANCE
          value: "true"
        image: josiahwolfoberholtzer/on-exactitude-in-science-api:latest
        livenessProbe:
          httpGet:
            path: /health
            port: 8080
          initialDelaySeconds: 5
          periodSeconds: 5
        ports:
        - containerPort: 8080
