# Copyright 2021 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: frontend
spec:
  selector:
    matchLabels:
      app: boa
      service: frontend
  template:
    metadata:
      labels:
        app: boa
        service: frontend
    spec:
      serviceAccountName: frontend
      terminationGracePeriodSeconds: 5
      containers:
        - name: front
          image: gcr.io/bank-of-anthos-ci/frontend:v0.5.3
          volumeMounts:
            - name: publickey
              mountPath: "/root/.ssh"
              readOnly: true
          env:
            - name: VERSION
              value: "v0.5.3"
            - name: PORT
              value: "8080"
            - name: ENABLE_TRACING
              value: "true"
            - name: SCHEME
              value: "https"
              # Valid levels are debug, info, warning, error, critical. If no valid level is set, defaults to info.
            - name: LOG_LEVEL
              value: "info"
            # Set to "true" to enable the CymbalBank logo + title
            # - name: CYMBAL_LOGO
            #   value: "false"
            # Customize the bank name used in the header. Defaults to 'Bank of Anthos' - when CYMBAL_LOGO is true, uses 'CymbalBank'
            # - name: BANK_NAME
            #   value: ""
            - name: DEFAULT_USERNAME
              valueFrom:
                configMapKeyRef:
                  name: demo-data-config
                  key: DEMO_LOGIN_USERNAME
            - name: DEFAULT_PASSWORD
              valueFrom:
                configMapKeyRef:
                  name: demo-data-config
                  key: DEMO_LOGIN_PASSWORD
          envFrom:
            - configMapRef:
                name: environment-config
            - configMapRef:
                name: service-api-config
          readinessProbe:
            httpGet:
              path: /ready
              port: 8080
            initialDelaySeconds: 10
            periodSeconds: 5
            timeoutSeconds: 10
          livenessProbe:
            httpGet:
              path: /ready
              port: 8080
            initialDelaySeconds: 60
            periodSeconds: 15
            timeoutSeconds: 30
          resources:
            requests:
              cpu: 100m
              memory: 64Mi
            limits:
              cpu: 500m
              memory: 256Mi
      volumes:
        - name: publickey
          secret:
            secretName: jwt-key
            items:
              - key: jwtRS256.key.pub
                path: publickey
---
apiVersion: v1
kind: Service
metadata:
  name: frontend
spec:
  type: ClusterIP
  selector:
    app: boa
    service: frontend
  ports:
    - name: http
      port: 80
      targetPort: 8080
