# Copyright 2020 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.

# Define deployment and service for ic.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: fhirproxy
  labels:
    name: fhirproxy
spec:
  replicas: 1
  selector:
    matchLabels:
      app: fhirproxy
      tier: web
  template:
    metadata:
      labels:
        app: fhirproxy
        tier: web
    spec:
      containers:
        - name: fhirproxy
          image: gcr.io/sof-test-apps/fhirproxy:latest
          ports:
            - containerPort: 8080
          env:
            - name: PROXY_PROJECT
              value: sof-test-apps
            - name: FHIR_ISSUER
              value: oidc_issue_url_placeholder
            - name: AUDIENCE
              value: audience_url_placeholder
            - name: PROXY_TO
              value: "https://healthcare.googleapis.com"
            - name: ALLOWED_PATH_PREFIX
              value: /
            - name: REMOVE_SCOPES
              value: openid
            - name: SERVICE_ACCOUNT_NAME
              value: fhiruser@sof-test-apps.iam.gserviceaccount.com
            - name: USE_USERINFO_TO_VERIFY_ACCESSTOKEN
              value: "false"
            - name: CACHE_ADDR
              value: ""
            - name: USE_SECRET_MANAGER
              value: "false"
          readinessProbe:
            httpGet:
              port: 8080
              path: /liveness_check
---
apiVersion: v1
kind: Service
metadata:
  name: fhirproxy-service
  labels:
    app: fhirproxy
spec:
  type: NodePort
  selector:
    app: fhirproxy
    tier: web
  ports:
    - name: public
      port: 8080
      targetPort: 8080
