# --------------------------------------------------------------------
# Copyright (c) 2020, WSO2 Inc. (http://wso2.com) All Rights Reserved.
#
# Licensed 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
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License 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.
# -----------------------------------------------------------------------

# Deployment for Adapter

apiVersion: apps/v1
kind: Deployment
metadata:
  name: choreo-connect-adapter
spec:
  replicas: 1
  selector:
    matchLabels:
      app: choreo-connect-adapter
  template:
    metadata:
      labels:
        app: choreo-connect-adapter
    spec:
      containers:
        - name: choreo-connect-adapter
          volumeMounts:
            - mountPath: /home/wso2/security/keystore
              name: adapter-keystore-vol
            - mountPath: /home/wso2/security/truststore
              name: adapter-truststore-vol
            - mountPath: /home/wso2/security/truststore/consul
              name: consul-certs-vol
            - mountPath: /home/wso2/conf/config.toml
              subPath: config.toml
              name: config-toml-vol
            - mountPath: /home/wso2/conf/log_config.toml
              subPath: log_config.toml
              name: logconfig-toml-vol
          image: wso2/choreo-connect-adapter:1.0.0-beta2-SNAPSHOT
          imagePullPolicy: IfNotPresent
          env:
            - name: ADAPTER_PRIVATE_KEY_PATH
              value: "/home/wso2/security/keystore/mg.key"
            - name: ADAPTER_PUBLIC_CERT_PATH
              value: "/home/wso2/security/keystore/mg.pem"
            - name: cp_admin_pwd
              value: "admin"
            - name: adapter_admin_pwd
              value: "admin"
          resources:
            requests:
              memory: "500Mi"
              cpu: "500m"
            limits:
              memory: "500Mi"
              cpu: "500m"
          ports:
            - containerPort: 18000
            - containerPort: 9843
          livenessProbe:
            exec:
              command: [ "sh", "check_health.sh" ]
            initialDelaySeconds: 10
            periodSeconds: 30
          readinessProbe:
            exec:
              command: [ "sh", "check_health.sh" ]
            initialDelaySeconds: 8
            periodSeconds: 5
      volumes:
        - name: adapter-keystore-vol
          secret:
            secretName: adapter-keystore
        - name: adapter-truststore-vol
          secret:
            secretName: adapter-truststore
        - name: consul-certs-vol
          secret:
            secretName: consul-certs
        - name: config-toml-vol
          configMap:
            name: config-toml
        - name: log4j2-vol
          configMap:
            name: log4j2
        - name: logconfig-toml-vol
          configMap:
            name: logconfig-toml
      restartPolicy: Always
