# Copyright 2021 The ParallelAccel Authors. 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: working_area-api
spec:
  selector:
    matchLabels:
      app: working_area-api
      tier: backend
  strategy:
    rollingUpdate:
      maxSurge: 50%
  template:
    metadata:
      labels:
        app: working_area-api
        tier: backend
    spec:
      containers:
        - name: esp
          env:
            - name: GCP_PROJECT
              valueFrom:
                configMapKeyRef:
                  name: working_area-api-config
                  key: GCP_PROJECT
            - name: SVC_NAME_SUFFIX
              valueFrom:
                configMapKeyRef:
                  name: working_area-api-config
                  key: SVC_NAME_SUFFIX
          envFrom:
            - configMapRef:
                name: working_area-api-config
          image: gcr.io/endpoints-release/endpoints-runtime:2
          args:
            [
              "--http_port=8081",
              "--backend=127.0.0.1:8080",
              "--rollout_strategy=managed",
              "--healthz=health",
REDACTED"
            ]
          ports:
            - containerPort: 8081
          resources:
            limits:
              cpu: 250m
            requests:
              cpu: 100m
          readinessProbe:
            httpGet:
              path: /health
              port: 8081
            initialDelaySeconds: 5
            periodSeconds: 5
        - name: api-service
          image: REDACTED
          imagePullPolicy: "Always"
          env:
            - name: GCP_PROJECT
              valueFrom:
                configMapKeyRef:
                  name: working_area-api-config
                  key: GCP_PROJECT
            - name: GKE_CLUSTER
              valueFrom:
                configMapKeyRef:
                  name: working_area-api-config
                  key: GKE_CLUSTER
          envFrom:
            - configMapRef:
                name: working_area-config
          ports:
            - containerPort: 8080
          resources:
            limits:
              cpu: 250m
            requests:
              cpu: 100m
          readinessProbe:
            httpGet:
              path: /health
              port: 8080
            initialDelaySeconds: 15
            periodSeconds: 5
