# Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) 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.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: wso2apim-pattern-2-is-as-km-deployment
spec:
  replicas: 1
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
    type: RollingUpdate
  selector:
    matchLabels:
      deployment: wso2apim-pattern-2-is-as-km
  template:
    metadata:
      labels:
        deployment: wso2apim-pattern-2-is-as-km
    spec:
      containers:
      - name: wso2apim-is-as-km
        image: wso2/wso2is-km:5.7.0
        livenessProbe:
          exec:
            command:
              - /bin/sh
              - -c
              - nc -z localhost 9443
          initialDelaySeconds: 240
          failureThreshold: 3
          periodSeconds: 10
        readinessProbe:
          exec:
            command:
              - /bin/sh
              - -c
              - nc -z localhost 9443
          initialDelaySeconds: 240
          failureThreshold: 3
          periodSeconds: 10
        lifecycle:
          preStop:
            exec:
              command:  ['sh', '-c', '${WSO2_SERVER_HOME}/bin/wso2server.sh stop']
        resources:
          requests:
            memory: 2Gi
            cpu: 2000m
          limits:
            memory: 3Gi
            cpu: 3000m
        imagePullPolicy: Always
        securityContext:
          runAsUser: 802
        ports:
        -
          containerPort: 9763
          protocol: "TCP"
        -
          containerPort: 9443
          protocol: "TCP"
        volumeMounts:
        - name: apim-is-as-km-storage-volume
          mountPath: /home/wso2carbon/wso2is-km-5.7.0/repository/deployment
        - name: apim-is-as-km-conf
          mountPath: /home/wso2carbon/wso2-config-volume/repository/conf
        - name: apim-is-as-km-conf-axis2
          mountPath: /home/wso2carbon/wso2-config-volume/repository/conf/axis2
        - name: apim-is-as-km-conf-datasources
          mountPath: /home/wso2carbon/wso2-config-volume/repository/conf/datasources
      serviceAccountName: "wso2svc-account"
      volumes:
      - name: apim-is-as-km-storage-volume
        persistentVolumeClaim:
          claimName: wso2apim-pattern-2-is-as-km-shared-server-volume-claim
      - name: apim-is-as-km-conf
        configMap:
          name: apim-is-as-km-conf
      - name: apim-is-as-km-conf-axis2
        configMap:
          name: apim-is-as-km-conf-axis2
      - name: apim-is-as-km-conf-datasources
        configMap:
          name: apim-is-as-km-conf-datasources
