## Copyright (c) 2021 Oracle and/or its affiliates.
## Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
apiVersion: apps/v1
kind: Deployment
metadata:
  name: order-helidon
spec:
  replicas: 1
  selector:
    matchLabels:
      app: order
  template:
    metadata:
      labels:
        app: order
        version: helidon-mp
    spec:
      containers:
      - name: order
        image: ${DOCKER_REGISTRY}/order-helidon:0.1
        imagePullPolicy: Always
        env:
        - name: oracle.ucp.jdbc.PoolDataSource.orderpdb.user
          value: "ORDERUSER"
        - name: oracle.ucp.jdbc.PoolDataSource.orderpdb.URL
          value: "jdbc:oracle:thin:@${ORDER_DB_ALIAS}?TNS_ADMIN=/msdataworkshop/creds"
        - name: queueowner
          value: "AQ"
        - name: orderqueuename
          value: "ORDERQUEUE"
        - name: inventoryqueuename
          value: "inventoryqueue"
        - name: OCI_REGION
          value: "${OCI_REGION-}"
        - name: VAULT_SECRET_OCID
          value: "${VAULT_SECRET_OCID-}"
        - name: dbpassword
          valueFrom:
            secretKeyRef:
              name: dbuser
              key: dbpassword
              optional: true #not needed/used if using VAULT_SECRET_OCID exists
        volumeMounts:
        - name: creds
          mountPath: /msdataworkshop/creds
        ports:
        - containerPort: 8080
        livenessProbe:
          httpGet: #alternatives include exec with command, etc.
            path: /health/live
            port: 8080
          initialDelaySeconds: 220
          periodSeconds: 3
        readinessProbe:
          httpGet:
            path: /health/ready
            port: 8080
          initialDelaySeconds: 40
          periodSeconds: 3
      restartPolicy: Always
      volumes:
      - name: creds
        secret:
          secretName: order-db-tns-admin-secret
      topologySpreadConstraints:
      - maxSkew: 1
        topologyKey: kubernetes.io/hostname
        whenUnsatisfiable: DoNotSchedule
        labelSelector:
          matchLabels:
            app: order
