# Copyright 2019 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: userservice-v2
  namespace: boa
spec:
  selector:
    matchLabels:
      app: userservice
  template:
    metadata:
      labels:
        app: userservice
        version: v2
    spec:
      terminationGracePeriodSeconds: 5
      containers:
      - name: userservice
        image: gcr.io/bank-of-anthos/userservice:v0.1.2
        volumeMounts:
        - name: keys
          mountPath: "/root/.ssh"
          readOnly: true
        ports:
        - name: http-server
          containerPort: 8080
        env:
        - name: VERSION
          value: "v2"
        - name: PORT
          value: "8080"
        - name: TOKEN_EXPIRY_SECONDS
          value: "3600"
        - name: PRIV_KEY_PATH
          value: "/root/.ssh/privatekey"
        envFrom:
        - configMapRef:
            name: environment-config
        - configMapRef:
            name: accounts-db-config
        readinessProbe:
          httpGet:
            path: /ready
            port: 8080
          initialDelaySeconds: 5
          periodSeconds: 5
      volumes:
      - name: keys
        secret:
          secretName: jwt-key
          items:
          - key: jwtRS256.key
            path: privatekey
          - key: jwtRS256.key.pub
            path: publickey
