apiVersion: "apps/v1"
kind: Deployment
metadata:
  name: mt-api-v1
  labels:
    app: mt-api
    version: "1"
    sla: bronze
    requests: "67"
    limits: "100"
    upgradeTime: "90"
spec:
  strategy: 
    type: "RollingUpdate"
    rollingUpdate:
      maxUnavailable: 0% 
      maxSurge: 100% 
  replicas: 1
  selector:
    matchLabels:
      app: mt-api
      version: "1"
      sla: bronze
  template:
    metadata:
      deletionGracePeriodSeconds: 60
      labels:
        app: mt-api
        version: "1"
        sla: bronze
    spec:
      nodeSelector:
        kubernetes.io/os: "linux"
        #deployable: "true"
      affinity:
        podAffinity: 
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 50
            podAffinityTerm:
              labelSelector:
                matchLabels:
                  app: mt-api
              topologyKey: "kubernetes.io/hostname"
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 80
              podAffinityTerm:
                labelSelector:
                  matchLabels:
                    version: "1"
                    sla: bronze
                topologyKey: "kubernetes.io/hostname"
      containers:
      - name: backend-v1
        readinessProbe:
          httpGet:
            path: /api/info/
            port: 8080
            httpHeaders: 
            - name: tenant-id
              value: "admin"
          initialDelaySeconds: 5
          periodSeconds: 2
          successThreshold: 1
        image: tourna/mt-api:v1
        imagePullPolicy: Always
        resources:
          requests:
            cpu: "871m"
          limits:
            cpu: "1300m"
        ports:
          - name: startup-port
            containerPort: 8080
        env:
        - name: DB_CONNECTION_STRING
          value: 'mongodb://mt-db-s/mt-api'
