# Copyright 2023 Google LLC
#
# 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: api-server
spec:
  selector:
    matchLabels:
      app: api-server
  template:
    metadata:
      labels:
        app: api-server
    spec:
      serviceAccountName: default
      terminationGracePeriodSeconds: 5
      securityContext:
        runAsNonRoot: true
        runAsGroup: 1000
        runAsUser: 1000
        fsGroup: 1000
      containers:
      - name: api-server
        image: us-docker.pkg.dev/point-of-sale-ci/pos-images/api-server:v0.3.0-jss
        securityContext:
          privileged: false
          allowPrivilegeEscalation: false
          runAsNonRoot: true
          capabilities:
            drop:
              - all
        env:
        - name: INVENTORY_EP
          valueFrom:
            configMapKeyRef:
              name: service-configs
              key: INVENTORY_EP
        - name: PAYMENTS_EP
          valueFrom:
            configMapKeyRef:
              name: service-configs
              key: PAYMENTS_EP
        resources:
          requests:
            cpu: 100m
            memory: 512Mi
          limits:
            cpu: 500m
            memory: 1Gi
        readinessProbe:
          httpGet:
            path: /api/ready
            port: 8080
          initialDelaySeconds: 60
          periodSeconds: 5
          timeoutSeconds: 10
        livenessProbe:
          httpGet:
            path: /api/healthy
            port: 8080
          initialDelaySeconds: 120
          periodSeconds: 5
          timeoutSeconds: 10
