apiVersion: apps/v1
kind: Deployment
metadata:
  name: airshelf-core-api
  labels:
    app: airshelf-core-api
spec:
  replicas: 1
  selector:
    matchLabels:
      app: airshelf-core-api
  template:
    metadata:
      labels:
        app: airshelf-core-api
    spec:
      imagePullSecrets:
      - name: cr-pull-secret
      containers:
      - name: airshelf-core-api
        image: ${CI_REGISTRY_IMAGE}/airshelf-core-api:latest
        imagePullPolicy: Always
        # No command override: the image ENTRYPOINT (docker-entrypoint.sh) runs
        # migrate + collectstatic, then the default CMD (gunicorn) is exec'd.
        ports:
        - containerPort: 8000
        envFrom:
        - secretRef:
            name: airshelf-core-env
        livenessProbe:
          httpGet:
            path: /api/health/
            port: 8000
            httpHeaders:
            - name: Host
              value: airshelf-web.airlabs.art
          initialDelaySeconds: 20
          periodSeconds: 15
          timeoutSeconds: 5
          failureThreshold: 3
        readinessProbe:
          httpGet:
            path: /api/health/
            port: 8000
            httpHeaders:
            - name: Host
              value: airshelf-web.airlabs.art
          initialDelaySeconds: 10
          periodSeconds: 10
          timeoutSeconds: 5
          failureThreshold: 3
        resources:
          requests:
            memory: "256Mi"
            cpu: "100m"
          limits:
            memory: "768Mi"
            cpu: "1000m"
---
apiVersion: v1
kind: Service
metadata:
  name: airshelf-core-api
spec:
  selector:
    app: airshelf-core-api
  ports:
    - protocol: TCP
      port: 8000
      targetPort: 8000
