apiVersion: apps/v1
kind: Deployment
metadata:
  name: retraced-api
  namespace: '{{repl ConfigOption "namespace"}}'
spec:
  selector:
    matchLabels:
      tier: api
  replicas: 2
  template:
    metadata:
      labels:
        app: auditlog
        tier: api
    spec:
      imagePullSecrets:
        - name: auditlog-imagepull-secret
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 1
            podAffinityTerm:
              labelSelector:
                matchExpressions:
                - key: app
                  operator: In
                  values:
                  - auditlog
                - key: tier
                  operator: In
                  values:
                  - api
              topologyKey: "kubernetes.io/hostname"
      containers:
        - name: api
          readinessProbe:
            httpGet:
              port: 3000
              path: /healthz
          image: registry.replicated.com/library/retraced:1.4.6
          imagePullPolicy: IfNotPresent
          command:
            - /src/api
          ports:
            - containerPort: 3000
              name: http
              protocol: TCP
          envFrom:
            - secretRef:
                name: auditlog
          env:
            - name: BUGSNAG_TOKEN
              valueFrom:
                secretKeyRef:
                  key: API_TOKEN
                  name: auditlog
            - name: PG_SEARCH
              value: ""
          resources:
            requests:
              cpu: 100m
            limits:
              cpu: 500m
