# ===============LICENSE_START=======================================================
# Acumos Apache-2.0
# ===================================================================================
# Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
# ===================================================================================
# This Acumos software file is distributed by AT&T and Tech Mahindra
# under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ===============LICENSE_END=========================================================

apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: <ACUMOS_NAMESPACE>
  name: mlwb-predictor
  labels:
    app: mlwb-predictor
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mlwb-predictor
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: mlwb-predictor
        <ACUMOS_SERVICE_LABEL_KEY>: <MLWB_CORE_SERVICE_LABEL>
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: <ACUMOS_SERVICE_LABEL_KEY>
                operator: NotIn
                values:
                - <MLWB_CORE_SERVICE_LABEL>
            topologyKey: "kubernetes.io/node"
      imagePullSecrets:
      - name: acumos-registry
      containers:
      - name: mlwb-model
        image: <MLWB_PREDICTOR_SERVICE_IMAGE>
        env:
        - name: SPRING_APPLICATION_JSON
          value: '{
              "server": {
                  "port": 9096
              },
              "dateformat": "yyyy-MM-dd-HH-mm-ss-SSS",
              "resultsetSize": 2000,
              "cmndatasvc": {
                  "url": "http://<ACUMOS_CDS_HOST>:<ACUMOS_CDS_PORT>/ccds",
                  "user": "<ACUMOS_CDS_USER>",
                  "pwd": "<ACUMOS_CDS_PASSWORD>"
              },
              "couchdb": {
                  "user": "<ACUMOS_COUCHDB_USER>",
                  "pwd": "<ACUMOS_COUCHDB_PASSWORD>",
                  "name": "<ACUMOS_COUCHDB_DB_NAME>",
                  "createdb": {
                      "if-not-exist": true
                  },
                  "protocol": "http",
                  "host": "<ACUMOS_COUCHDB_DOMAIN>",
                  "port": <ACUMOS_COUCHDB_PORT>
              },
              "projectservice": {
                  "url": "http://mlwb-project-service:9088/mlWorkbench/v1/project"
              },
              "modelservice": {
                  "url": "http://mlwb-model-service:9091/mlWorkbench/v1/modelservice"
              },
              "jwt": {
                  "secretkey": "<ACUMOS_JWT_KEY>"
              }
          }'
        ports:
        - containerPort: 9096
        volumeMounts:
        - mountPath: /maven/logs
          name: logs
      restartPolicy: Always
      volumes:
      - name: logs
        persistentVolumeClaim:
          claimName: <MLWB_CORE_SERVICE_LABEL>
