# 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: inventory
spec:
  selector:
    matchLabels:
      app: inventory
  template:
    metadata:
      labels:
        app: inventory
    spec:
      serviceAccountName: "{{ .Values.service_account }}"
      terminationGracePeriodSeconds: 5
      securityContext:
        runAsNonRoot: true
        runAsGroup: 1000
        runAsUser: 1000
        fsGroup: 1000
      containers:
        - name: inventory
          image: us-docker.pkg.dev/point-of-sale-ci/pos-images/inventory:v0.3.0-jss
          securityContext:
            privileged: false
            allowPrivilegeEscalation: false
            runAsNonRoot: true
            capabilities:
              drop:
                - all
          env:
            - name: SPRING_PROFILES_ACTIVE
              valueFrom:
                configMapKeyRef:
                  name: spring-profile
                  key: SPRING_PROFILES_ACTIVE
            - name: ACTIVE_ITEM_TYPE
              valueFrom:
                configMapKeyRef:
                  name: service-configs
                  key: ACTIVE_ITEM_TYPE
            - name: ITEMS
              valueFrom:
                configMapKeyRef:
                  name: service-configs
                  key: ITEMS
            - name: PROJECT_ID
              valueFrom:
                configMapKeyRef:
                  name: service-configs
                  key: PROJECT_ID
            - name: SPANNER_ID
              valueFrom:
                configMapKeyRef:
                  name: service-configs
                  key: SPANNER_ID
            - name: SPANNER_DATABASE
              valueFrom:
                configMapKeyRef:
                  name: service-configs
                  key: SPANNER_DATABASE
          resources:
            requests:
              cpu: 500m
              memory: 512Mi
            limits:
              cpu: 1000m
              memory: 1Gi
          readinessProbe:
            httpGet:
              path: /ready
              port: 8080
            initialDelaySeconds: 60
            periodSeconds: 5
            timeoutSeconds: 10
          livenessProbe:
            httpGet:
              path: /healthy
              port: 8080
            initialDelaySeconds: 120
            periodSeconds: 5
            timeoutSeconds: 10
