apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    name: prep-app
  name: prep-app
  namespace: prep
spec:
  progressDeadlineSeconds: 2147483647
  replicas: 1
  revisionHistoryLimit: 2
  selector:
    matchLabels:
      name: prep-app
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        name: prep-app
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: type
                    operator: In
                    values:
                      - webapps
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - podAffinityTerm:
                labelSelector:
                  matchExpressions:
                    - key: name
                      operator: In
                      values:
                        - prep-app
                topologyKey: kubernetes.io/hostname
              weight: 100
      containers:
        - env:
            - name: PORT
              value: "3000"
            - name: NODE_ENV
              value: production
            - name: SHORT_URL_API_TOKEN
              valueFrom:
                secretKeyRef:
                  key: PREP_SHORT_URL_API_TOKEN
                  name: appsecrets
            - name: SPARKPOST_API_KEY
              valueFrom:
                secretKeyRef:
                  key: PREP_SPARKPOST_API_KEY
                  name: appsecrets
            - name: MAIL_RECIPIENTS
              valueFrom:
                secretKeyRef:
                  key: PREP_MAIL_RECIPIENTS
                  name: appsecrets
            - name: MAIL_FROM
              valueFrom:
                secretKeyRef:
                  key: PREP_MAIL_FROM
                  name: appsecrets
            - name: TWITTER_CONSUMER_KEY
              valueFrom:
                secretKeyRef:
                  key: PREP_TWITTER_CONSUMER_KEY
                  name: appsecrets
            - name: TWITTER_CONSUMER_SECRET
              valueFrom:
                secretKeyRef:
                  key: PREP_TWITTER_CONSUMER_SECRET
                  name: appsecrets
            - name: TWITTER_ACCESS_TOKEN_KEY
              valueFrom:
                secretKeyRef:
                  key: PREP_TWITTER_ACCESS_TOKEN_KEY
                  name: appsecrets
            - name: TWITTER_ACCESS_TOKEN_SECRET
              valueFrom:
                secretKeyRef:
                  key: PREP_TWITTER_ACCESS_TOKEN_SECRET
                  name: appsecrets
          image: gfwdockerhub/prep-app
          imagePullPolicy: Always
          name: prep-app
          ports:
            - containerPort: 3000
              protocol: TCP
          resources:
            limits:
              cpu: "1"
              memory: 512M
            requests:
              cpu: 500m
              memory: 256M
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      imagePullSecrets:
        - name: regcred
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: { }
      terminationGracePeriodSeconds: 30
