# Copyright (c) 2016, 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-analytics-worker-deployment
spec:
  replicas: 1
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
    type: RollingUpdate
  selector:
    matchLabels:
      deployment: wso2apim-pattern-2-analytics
  template:
    metadata:
      labels:
        deployment: wso2apim-pattern-2-analytics
    spec:
      containers:
      - name: wso2apim-analytics-worker
        image: wso2/wso2am-analytics-worker:2.6.0
        livenessProbe:
          exec:
            command:
            - /bin/sh
            - -c
            - nc -z localhost 9444
          initialDelaySeconds: 30
          failureThreshold: 3
          periodSeconds: 10
        readinessProbe:
          exec:
            command:
              - /bin/sh
              - -c
              - nc -z localhost 9444
          initialDelaySeconds: 30
          failureThreshold: 3
          periodSeconds: 10
        lifecycle:
          preStop:
            exec:
              command:  ['sh', '-c', '${WSO2_SERVER_HOME}/bin/worker.sh stop']
        resources:
          requests:
            memory: "4Gi"
            cpu: "2000m"
          limits:
            memory: "4Gi"
            cpu: "2000m"
        securityContext:
          runAsUser: 802
        ports:
        -
          containerPort: 7712
          protocol: "TCP"
        -
          containerPort: 7612
          protocol: "TCP"
        -
          containerPort: 9713
          protocol: "TCP"
        -
          containerPort: 9613
          protocol: "TCP"
        -
          containerPort: 9091
          protocol: "TCP"
        -
          containerPort: 9444
          protocol: "TCP"
        -
          containerPort: 7444
          protocol: "TCP"
        -
          containerPort: 7071
          protocol: "TCP"
        volumeMounts:
        - name: apim-analytics-conf-worker
          mountPath: /home/wso2carbon/wso2-config-volume/conf/worker
      serviceAccountName: "wso2svc-account"
      volumes:
      - name: apim-analytics-conf-worker
        configMap:
          name: apim-analytics-conf-worker
