## 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: db-log-exporter-orderpdb
spec:
  replicas: 1
  selector:
    matchLabels:
      app: db-log-exporter-orderpdb
  template:
    metadata:
      labels:
        app: db-log-exporter-orderpdb
        version: helidon-mp
    spec:
      containers:
      - name: db-log-exporter
        image: ${DOCKER_REGISTRY}/db-log-exporter:0.1
        imagePullPolicy: Always
        env:
        - name: oracle.ucp.jdbc.PoolDataSource.alertlogpdb.user
          value: "ORDERUSER"
        - name: oracle.ucp.jdbc.PoolDataSource.alertlogpdb.URL
          value: "jdbc:oracle:thin:@${ORDER_DB_ALIAS}?TNS_ADMIN=/msdataworkshop/creds"
        - name: oracle.ucp.jdbc.PoolDataSource.alertlogpdb.password
          valueFrom:
            secretKeyRef:
              name: dbuser
              key: dbpassword
              optional: true
#       The following QUERY_SQL can be any query but must contain EXECUTION_CONTEXT_ID
        - name: QUERY_SQL
          value: "select ORIGINATING_TIMESTAMP, MODULE_ID, EXECUTION_CONTEXT_ID, MESSAGE_TEXT from V$diag_alert_ext"
        - name: OCI_REGION
          value: "${OCI_REGION-}"
        - name: VAULT_SECRET_OCID
          value: "${VAULT_SECRET_OCID-}"
        volumeMounts:
        - name: creds
          mountPath: /msdataworkshop/creds
        ports:
        - containerPort: 8080
      restartPolicy: Always
      volumes:
      - name: creds
        secret:
          secretName: order-db-tns-admin-secret