# 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
#
#     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: v1
kind: Service
metadata:
  name: demo-app
  labels:
    app: demo-app
spec:
  ports:
  - port: 8080
    protocol: TCP
  clusterIP: None
  selector:
    app: demo-app
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: demo-app
  labels:
    app: demo-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: demo-app
  template:
    metadata:
      labels:
        app: demo-app
    spec:
      containers:
      - name: demo-app
        image: demo-app
        env:
          - name: PORT
            value: "8080"
          
          # Disabled if not using the CloudSQL Database

          # - name: TARGET
          #   value: "Local Dev - CloudSQL Database - K8s Cluster"
          # # set the profile to use
          # - name: SPRING_PROFILES_ACTIVE
          #   value: cloud-dev
          # - name: DB_HOST
          #   value: "172.24.0.3"        
          # - name: DB_PORT
          #   value: "5432"  
          # - name: DB_USER
          #   valueFrom:
          #     secretKeyRef:
          #       name: gke-cloud-sql-secrets
          #       key: username
          # - name: DB_PASS
          #   valueFrom:
          #     secretKeyRef:
          #       name: gke-cloud-sql-secrets
          #       key: password
          # - name: DB_NAME
          #   valueFrom:
          #     secretKeyRef:
          #       name: gke-cloud-sql-secrets
          #       key: database       