# Copyright 2022 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: orderservice
spec:
  replicas: 1
  selector:
    matchLabels:
      app: orderservice
  template:
    metadata:
      name: orderservice
      labels:
        app: orderservice
    spec:
      initContainers:
        - name: init
          image: ubuntu:latest
          command: [ '/bin/bash', '-c', "while [ ! -f /data/ready ]; do sleep 1; done" ]
          volumeMounts:
            - name: data
              mountPath: "/data"
      containers:
        - name: orderservice
          image: ubuntu:latest
          command: ["/bin/bash", "-c"]
          env:
            - name: DISABLE_TRACING
              value: "true"
            - name: CHECKOUT_SERVICE
              value: "checkoutservice:5050"
            - name: CART_SERVICE
              value: "cartservice:7070"
          args: ["./data/orderservice"]
          ports:
            - name: grpc
              containerPort: 9090
          volumeMounts:
            - name: data
              mountPath: "/data"
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: 'orderservice-pvc'
---
apiVersion: v1
kind: Service
metadata:
  name: orderservice
  labels:
    app: orderservice
spec:
  ports:
    - port: 9090
      name: grpc
  selector:
    app: orderservice