apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: nxs
  name: workload-manager
  labels:
    name: workload-manager
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      name: workload-manager-svc
  template:
    metadata:
      labels:
        name: workload-manager-svc
    spec:
      subdomain: nxs
      containers:
      - image: ${IMAGE}:${IMAGE_TAG}
        imagePullPolicy: IfNotPresent
        name: workload-manager
        resources:
          requests:
            cpu: ${CPU_REQUEST}
            memory: ${MEMORY_REQUEST}
        command:
          - "/bin/bash"
          #- "-c"
          #- "sleep 100000000"
          - "/app/scripts/run_workload_manager.sh"
        volumeMounts:
        - name: kv-secrets-store
          mountPath: "/mnt/secrets-store"
          readOnly: true
        env:
        - name: MY_POD_IP
          valueFrom:
            fieldRef:
              fieldPath: status.podIP
        - name: NEXUS_LOG_LEVEL
          value: "INFO"
        - name: COSMOSDB_URL
          valueFrom:
            secretKeyRef:
              name: nxskv
              key: MONGODB_CONNECTION_STR
        - name: COSMOSDB_NAME
          valueFrom:
            secretKeyRef:
              name: nxskv
              key: MONGODB_MAINDB_NAME
        - name: BLOBSTORE_CONN_STR
          valueFrom:
            secretKeyRef:
              name: nxskv
              key: BLOBSTORE_CONNECTION_STR
        - name: BLOBSTORE_CONTAINER
          valueFrom:
            secretKeyRef:
              name: nxskv
              key: BLOBSTORE_CONTAINER_NAME
        - name: REDIS_ADDRESS
          valueFrom:
            secretKeyRef:
              name: nxskv
              key: REDIS_ADDRESS
        - name: REDIS_PASSWORD
          valueFrom:
            secretKeyRef:
              name: nxskv
              key: REDIS_PASSWORD
        - name: REDIS_PORT
          valueFrom:
            secretKeyRef:
              name: nxskv
              key: REDIS_PORT
        - name: REDIS_USE_SSL
          valueFrom:
            secretKeyRef:
              name: nxskv
              key: REDIS_USE_SSL
        - name: TMP_DIR
          value: "/app/tmp"   
      imagePullSecrets:
      - name: regcred
      nodeSelector:
        restype: cpu
      volumes:
      - name: kv-secrets-store
        csi:
          driver: secrets-store.csi.k8s.io
          readOnly: true
          volumeAttributes:
            secretProviderClass: "nxs-kv-sync"
