#
# Deploy the back end data API microservice in Kubernetes
#
# !IMPORTANT! Change the image reference to point to the registry holding
# the Smilr images, either ACR or public

kind: Deployment
apiVersion: apps/v1
metadata:
  name: data-api
  labels:
    app: data-api
spec:
  replicas: 3
  selector:
    matchLabels:
      app: data-api
  template:
    metadata:
      labels:
        app: data-api
    spec:
      containers:
      - name: data-api-pods

        # !CHANGE THIS! To your real image reference for the data-api  
        image: bcdemo.azurecr.io/smilr/data-api:stable
        imagePullPolicy: Always

        ports:
        - containerPort: 4000

        env:     
        - name: MONGO_CONNSTR
          value: mongodb://mongodb-svc.default
          #value: mongodb://smilr-demo:blah@smilr-demo.documents.azure.com:10255/?ssl=true&replicaSet=globaldb

        livenessProbe:
          httpGet:
            path: /api/info
            port: 4000
          initialDelaySeconds: 3
          periodSeconds: 20

        resources:
          limits:
            memory: "256M"
            cpu: "0.1"
            
      # Wipe & initialize the database with demo data, remove if unwanted
      initContainers:
       - name: init-demodata
         image: bcdemo.azurecr.io/smilr/data-api
         command: ['sh', '-c', 'cd demoData && node demoData.js']
         env:
           - name: MONGO_CONNSTR
             value: mongodb://mongodb-svc.default
           - name: WIPE_DB
             value: "1"