apiVersion: apps/v1
kind: Deployment
metadata:
  name: daytrader-service
  annotations:
    injection.smarttuning.ibm.com: "true"
spec:
  selector:
    matchLabels:
      app: daytrader
      smarttuning: "false"
  replicas: 1
  template:
    metadata:
      labels:
        app: daytrader
        smarttuning: "false"
      annotations:
        prometheus.io/scrape: 'true'
        prometheus.io/port: '9080'
    spec:
      restartPolicy: Always
      containers:
        - name: daytrader
          image: smarttuning/daytrader8-db2   # update port to 50000
          imagePullPolicy: IfNotPresent
          resources:
            limits:
              cpu: "3"
              memory: "512Mi"
          ports:
            - containerPort: 9080
          env:
            - name: DB_ADDRESS
              value: daytrader-db.default.svc.cluster.local
            - name: DB_PORT
              value: "50000"
            - name: DB_NAME
              value: "tradedb"
            - name: DB_USER
              value: "db2inst1"
            - name: DB_PASS
              value: "db2pass"
            - name: MAX_QUOTES
              value: "1000"
            - name: MAX_USERS
              value: "500"
#            - name: TRACE_SLOW_REQUEST_THRESHOLD
#              value: "1s"
#            - name: TRACE_HUNG_REQUEST_THRESHOLD
#              value: "2s"
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: LOG_DIR
              value: /home/$(POD_NAME)
          envFrom:
            - configMapRef:
                name: daytrader-config-app
          volumeMounts:
            - mountPath: /etc/daytrader-config-app
              name: daytrader-config-app
            - mountPath: /config/jvm.options
              subPath: jvm.options
              name: daytrader-config-jvm
          securityContext:
            # run as root
            runAsUser: 0
            privileged: true
      volumes:
        - name: daytrader-config-app
          configMap:
            name: daytrader-config-app
        - name: daytrader-config-jvm
          configMap:
            name: daytrader-config-jvm
