## 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-metrics-exporter-%EXPORTER_NAME%
spec:
  replicas: 1
  selector:
    matchLabels:
      app: db-metrics-exporter-%EXPORTER_NAME%
  template:
    metadata:
      labels:
        app: db-metrics-exporter-%EXPORTER_NAME%
    spec:
      containers:
        - name: db-metrics-exporter-%EXPORTER_NAME%
          image: iamseth/oracledb_exporter:latest #todo never a good idea to use "latest"
          imagePullPolicy: Always
          env:
            - name: DEFAULT_METRICS
              value: /msdataworkshop/observability/db-metrics-%EXPORTER_NAME%-exporter-metrics.toml
#            - name: CUSTOM_METRICS
#              value: /msdataworkshop/observability/db-metrics-%EXPORTER_NAME%-exporter-metrics.toml
            - name: TNS_ADMIN
              value: "/msdataworkshop/creds"
#          value: "/lib/oracle/instantclient_19_3/client64/lib/network/admin"
            - name: dbpassword
              valueFrom:
                secretKeyRef:
                  name: dbuser
                  key: dbpassword
                  optional: true
            - name: DATA_SOURCE_NAME
              value: "%USER%/$(dbpassword)@%PDB_NAME%_tp"
          volumeMounts:
            - name: creds
              mountPath: /msdataworkshop/creds
          #          mountPath: /lib/oracle/instantclient_19_3/client64/lib/network/admin # 19.10
            - name: config-volume
              mountPath: /msdataworkshop/observability/db-metrics-%EXPORTER_NAME%-exporter-metrics.toml
              subPath: db-metrics-%EXPORTER_NAME%-exporter-metrics.toml
          ports:
            - containerPort: 8080
      restartPolicy: Always
      volumes:
        - name: creds
          secret:
            secretName: db-wallet-secret
        - name: config-volume
          configMap:
            name: db-metrics-%EXPORTER_NAME%-exporter-config
#        - name: config-default-volume
#          configMap:
#            name: default-metrics-exporter-config