apiVersion: apps/v1
# ===============LICENSE_START=======================================================
# Acumos Apache-2.0
# ===================================================================================
# Copyright (C) 2017-2018 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=========================================================

# What this is: kubernetes template for Acumos dsce deployment
# How to use:

kind: Deployment
metadata:
  namespace: <ACUMOS_NAMESPACE>
  name: dsce
  labels:
    app: dsce
spec:
  replicas: 1
  selector:
    matchLabels:
      app: dsce
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: dsce
        <ACUMOS_SERVICE_LABEL_KEY>: <ACUMOS_ACUCOMPOSE_SERVICE_LABEL>
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: <ACUMOS_SERVICE_LABEL_KEY>
                operator: NotIn
                values:
                - <ACUMOS_ACUCOMPOSE_SERVICE_LABEL>
            topologyKey: "kubernetes.io/node"
      imagePullSecrets:
      - name: acumos-registry
      containers:
      - name: dsce
        image: <DESIGNSTUDIO_IMAGE>
        command: ["/bin/sh", "-c"]
        args:
        - set -x;
          cd maven;
          java $JAVA_OPTS -Dhttp.proxyHost=$ACUMOS_HTTP_PROXY_HOST -Dhttp.proxyPort=$ACUMOS_HTTP_PROXY_PORT -Dhttp.nonProxyHosts=$ACUMOS_HTTP_NON_PROXY_HOSTS -Dhttps.proxyHost=$ACUMOS_HTTP_PROXY_HOST -Dhttps.proxyPort=$ACUMOS_HTTP_PROXY_PORT -Dhttps.nonProxyHosts=$ACUMOS_HTTP_NON_PROXY_HOSTS -Djava.security.egd=file:/dev/./urandom -jar *.jar
        env:
        - name: ACUMOS_HTTP_NON_PROXY_HOSTS
          value: "<ACUMOS_HTTP_NON_PROXY_HOSTS>|cds-service"
        - name: ACUMOS_HTTP_PROXY_HOST
          value: "<ACUMOS_HTTP_PROXY_HOST>"
        - name: ACUMOS_HTTP_PROXY_PORT
          value: "<ACUMOS_HTTP_PROXY_PORT>"
        - name: JAVA_OPTS
          value: "-Xms128m -Xmx512m"
        - name: SPRING_APPLICATION_JSON
          value: '{
            "logging": {
              "level": {
                "root": "INFO"
              }
            },
            "server": {
              "port": 8088
            },
            "gdmJarName":"gdmservice-1.2.0-SNAPSHOT.jar",
            "dateformat": "yyyy-MM-dd-HH-mm-ss-SSS",
            "solutionResultsetSize": "2000",
            "cdsCheckInterval": 20000,
            "cdsCheckAttempt": 10,
            "imagedatabrokerURI": "<DATABROKER_ZIPBROKER_IMAGE>",
            "csvdatabrokerURI": "<DATABROKER_CSVBROKER_IMAGE>",
            "sqldatabrokerURI": "<DATABROKER_SQLBROKER_IMAGE>",
            "jsondatabrokerURI": "NA",
            "sqldatabrokerURI": "NA",
            "lib":"/maven/",
            "tosca": {
              "outputfolder": "/tmp/output/"
            },
            "nexus": {
              "nexusendpointurl": "http://<ACUMOS_NEXUS_HOST>:<ACUMOS_NEXUS_API_PORT>/<ACUMOS_NEXUS_MAVEN_REPO_PATH>/<ACUMOS_NEXUS_MAVEN_REPO>/",
              "nexusproxy": "",
              "nexuspassword": "<ACUMOS_NEXUS_RW_USER_PASSWORD>",
              "nexususername": "<ACUMOS_NEXUS_RW_USER>",
              "nexusgroupid": "<ACUMOS_NEXUS_GROUP>"
            },
            "cmndatasvc": {
              "cmndatasvcendpoinurl": "http://<ACUMOS_CDS_HOST>:<ACUMOS_CDS_PORT>/ccds",
              "cmndatasvcuser": "<ACUMOS_CDS_USER>",
              "cmndatasvcpwd": "<ACUMOS_CDS_PASSWORD>"
            },
            "docker": {
              "host": "<ACUMOS_DOCKER_API_HOST>",
              "port": "<ACUMOS_DOCKER_API_PORT>",
              "config": "/docker_host/.docker",
              "registry": {
                "url": "http://<ACUMOS_DOCKER_REGISTRY_HOST>:<ACUMOS_DOCKER_MODEL_PORT>/",
                "username": "<ACUMOS_DOCKER_REGISTRY_USER>",
                "password": "<ACUMOS_DOCKER_REGISTRY_PASSWORD>",
                "email": "<ACUMOS_ADMIN_EMAIL>"
              },
              "tls": {"verify": "false"},
              "api": {"version": "1.23"},
              "imagetag": {
                "prefix": "<ACUMOS_DOCKER_REGISTRY_HOST>:<ACUMOS_DOCKER_MODEL_PORT>"
              },
              "max_total_connections": "1",
              "max_per_route_connections": "1"
            }
          }'
        ports:
        - containerPort: 8088
        volumeMounts:
        - mountPath: /maven/logs
          name: logs
      restartPolicy: Always
      volumes:
      - name: logs
        persistentVolumeClaim:
         claimName: <ACUMOS_ACUCOMPOSE_SERVICE_LABEL>
