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 azure-client deployment
# How to use:

kind: Deployment
metadata:
  namespace: <ACUMOS_NAMESPACE>
  name: azure-client
  labels:
    app: azure-client
spec:
  replicas: 1
  selector:
    matchLabels:
      app: azure-client
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: azure-client
        <ACUMOS_SERVICE_LABEL_KEY>: <ACUMOS_AZURE_CLIENT_SERVICE_LABEL>
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: <ACUMOS_SERVICE_LABEL_KEY>
                operator: NotIn
                values:
                - <ACUMOS_AZURE_CLIENT_SERVICE_LABEL>
            topologyKey: "kubernetes.io/node"
      imagePullSecrets:
      - name: acumos-registry
      containers:
      - name: azure-client
        image: <AZURE_CLIENT_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|kubernetes-client-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": 9081
            },
            "docker": {
              "containerNamePrefix": "E6E-NSG",
              "host": "<ACUMOS_DOCKER_API_HOST>",
              "port": "<ACUMOS_DOCKER_API_PORT>",
              "dockerVMUserName": "<ACUMOS_DEPLOYED_VM_USER>",
              "dockerVMPassword": "<ACUMOS_DEPLOYED_VM_PASSWORD>",
              "replaceChar": "^",
              "ignordoller": "TRUE",
              "solutionPort": "<ACUMOS_DEPLOYED_SOLUTION_PORT>",
              "subnet": "Acumos-OAM-vsubnet",
              "vnet": "Acumos-OAM-vnet",
              "sleepTimeFirst": "30000",
              "sleepTimeSecond": "50000",
              "nexusRegistyUserName": "<ACUMOS_PROJECT_NEXUS_USERNAME>",
              "nexusRegistyPwd": "<ACUMOS_PROJECT_NEXUS_PASSWORD>",
              "nexusRegistyName": "nexus3.acumos.org",
              "otherRegistyName": "<ACUMOS_NEXUS_HOST>",
              "nginxMapFolder": "/home/artifacts",
              "nginxWebFolder": "/usr/share/nginx/html",
              "nginxImageName": "nginx:latest",
              "nginxInternalPort": "80",
              "kubernetesClientUrl":"http://kubernetes-client-service:8082/getSolutionZip",
              "exposeDataBrokerPort": "<ACUMOS_DATA_BROKER_PORT>",
              "internalDataBrokerPort": "<ACUMOS_DATA_BROKER_INTERNAL_PORT>",
              "registry": {
                "bluePrint": {
                  "username": "<ACUMOS_NEXUS_RW_USER>",
                  "password": "<ACUMOS_NEXUS_RW_USER_PASSWORD>"
                },
                "probe": {
                  "username": "<ACUMOS_NEXUS_RW_USER>",
                  "password": "<ACUMOS_NEXUS_RW_USER_PASSWORD>"
                },
                "networkgroupName": "acumos-nsg",
                "port": "80",
                "name": "<ACUMOS_DOCKER_REGISTRY_HOST>:<ACUMOS_DOCKER_MODEL_PORT>",
                "url": "http://<ACUMOS_DOCKER_REGISTRY_HOST>:<ACUMOS_DOCKER_MODEL_PORT>/",
                "username": "<ACUMOS_DOCKER_REGISTRY_USER>",
                "password": "<ACUMOS_DOCKER_REGISTRY_PASSWORD>"
              }
            },
            "blueprint": {
              "ImageName": "<BLUEPRINT_ORCHESTRATOR_IMAGE>",
              "name": "blueprint-orchestrator"
            },
            "nexus": {
              "url": "http://<ACUMOS_NEXUS_HOST>:<ACUMOS_NEXUS_API_PORT>/<ACUMOS_NEXUS_MAVEN_REPO_PATH>/<ACUMOS_NEXUS_MAVEN_REPO>/",
              "nexusproxy": "NA",
              "password": "<ACUMOS_NEXUS_RW_USER_PASSWORD>",
              "username": "<ACUMOS_NEXUS_RW_USER>",
              "groupId": "<ACUMOS_NEXUS_GROUP>"
            },
            "cmndatasvc": {
              "cmndatasvcendpoinurl": "http://<ACUMOS_CDS_HOST>:<ACUMOS_CDS_PORT>/ccds",
              "cmndatasvcuser": "<ACUMOS_CDS_USER>",
              "cmndatasvcpwd": "<ACUMOS_CDS_PASSWORD>"
            },
            "probe": {
              "ImageName": "<PROTO_VIEWER_IMAGE>",
              "name": "proto_viewer",
              "internalPort": "<ACUMOS_PROBE_PORT>",
              "probeNexusEndPoint": "http://<ACUMOS_NEXUS_HOST>:<ACUMOS_NEXUS_API_PORT>/<ACUMOS_NEXUS_MAVEN_REPO_PATH>/<ACUMOS_NEXUS_MAVEN_REPO>"
            }
          }'
        ports:
        - containerPort: 9081
        volumeMounts:
        - mountPath: /maven/logs
          name: logs
      restartPolicy: Always
      volumes:
      - name: logs
        persistentVolumeClaim:
         claimName: <ACUMOS_AZURE_CLIENT_SERVICE_LABEL>
