# Copyright 2024 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
#
#      https://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: shoppingassistantservice
  labels:
    app: shoppingassistantservice
spec:
  selector:
    matchLabels:
      app: shoppingassistantservice
  template:
    metadata:
      labels:
        app: shoppingassistantservice
    spec:
      serviceAccountName: shoppingassistantservice
      terminationGracePeriodSeconds: 5
      securityContext:
        fsGroup: 1000
        runAsGroup: 1000
        runAsNonRoot: true
        runAsUser: 1000
      containers:
      - name: server
        securityContext:
          allowPrivilegeEscalation: false
          capabilities:
            drop:
              - ALL
          privileged: false
          readOnlyRootFilesystem: false
        image: shoppingassistantservice
        ports:
        - name: http
          containerPort: 8080
        env:
        - name: GOOGLE_API_KEY
          value: GOOGLE_API_KEY_VAL
        - name: ALLOYDB_CLUSTER_NAME
          value: ALLOYDB_CLUSTER_NAME_VAL
        - name: ALLOYDB_INSTANCE_NAME
          value: ALLOYDB_INSTANCE_NAME_VAL
        - name: ALLOYDB_DATABASE_NAME
          value: ALLOYDB_DATABASE_NAME_VAL
        - name: ALLOYDB_TABLE_NAME
          value: ALLOYDB_TABLE_NAME_VAL
        - name: ALLOYDB_SECRET_NAME
          value: ALLOYDB_SECRET_NAME_VAL
        - name: PROJECT_ID
          value: PROJECT_ID_VAL
        - name: REGION
          value: REGION_VAL
        resources:
          requests:
            cpu: 100m
            memory: 64Mi
          limits:
            cpu: 200m
            memory: 128Mi
---
apiVersion: v1
kind: Service
metadata:
  name: shoppingassistantservice
  labels:
    app: shoppingassistantservice
spec:
  type: ClusterIP
  selector:
    app: shoppingassistantservice
  ports:
  - name: http
    port: 80
    targetPort: 8080
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: shoppingassistantservice
  annotations:
    iam.gke.io/gcp-service-account: ALLOYDB_USER_GSA_ID
