apiVersion: apps/v1
kind: Deployment
metadata:
  name: id-mapper-production
spec:
  selector:
    matchLabels:
      app: id-mapper
      env: production
  replicas: 1
  template:
    metadata:
      labels:
        app: id-mapper
        env: production
    spec:
      containers:
      - name: web
        image: gcr.io/dd-decaf-cfbf6/id-mapper:master
        imagePullPolicy: Always
        ports:
        - containerPort: 8000
        env:
        - name: ENVIRONMENT
          value: production
        - name: SCRIPT_NAME
          value: /id-mapper
        - name: FLASK_APP
          value: src/id_mapper/wsgi.py
        - name: ALLOWED_ORIGINS
          value: "*"
        - name: SECRET_KEY
          valueFrom:
            secretKeyRef:
              name: id-mapper-production
              key: SECRET_KEY
        - name: SENTRY_DSN
          valueFrom:
            secretKeyRef:
              name: id-mapper-production
              key: SENTRY_DSN
        - name: ID_MAPPER_API
          valueFrom:
            secretKeyRef:
              name: id-mapper-production
              key: ID_MAPPER_API
        - name: ID_MAPPER_PORT
          valueFrom:
            secretKeyRef:
              name: id-mapper-production
              key: ID_MAPPER_PORT
        - name: ID_MAPPER_USER
          valueFrom:
            secretKeyRef:
              name: id-mapper-production
              key: ID_MAPPER_USER
        - name: ID_MAPPER_PASSWORD
          valueFrom:
            secretKeyRef:
              name: id-mapper-production
              key: ID_MAPPER_PASSWORD
        readinessProbe:
          httpGet:
            path: /id-mapper/healthz
            port: 8000
          initialDelaySeconds: 5
        resources:
          requests:
            cpu: "1m"
          limits:
            cpu: "2000m"
      - name: db
        image: neo4j:3.1
        imagePullPolicy: Always
        ports:
        - containerPort: 7474
        env:
        - name: NEO4J_AUTH
          valueFrom:
            secretKeyRef:
              name: id-mapper-production
              key: NEO4J_AUTH
        resources:
          requests:
            cpu: "1m"
          limits:
            cpu: "2000m"
        volumeMounts:
          - mountPath: "/data"
            name: id-mapper-production
      volumes:
        - name: id-mapper-production
          persistentVolumeClaim:
           claimName: id-mapper-production
