apiVersion: apps/v1
kind: Deployment
metadata:
  name: userprofile
  namespace: api-dev
  labels:
    app: userprofile
spec:
  replicas: 1
  selector:
    matchLabels:
      app: userprofile
  template:
    metadata:
      labels:
        app: userprofile
    spec:
      volumes:
        - name: secrets-store-inline
          csi:
            driver: secrets-store.csi.k8s.io
            readOnly: true
            volumeAttributes:
              secretProviderClass: "azure-sync"
      containers:
      - name: userprofile
        image: registryjrj5155/userprofile:latest
        env:
          - name: SQL_USER
            valueFrom:
              secretKeyRef:
                name: sqluser #k8s secret name. (kubectl get secret). this is auto synced during creation and deletion of the POD
                key: sqluser #this must match the kv configuration in the yaml under secretObjects
          - name: SQL_PASSWORD
            valueFrom:
              secretKeyRef:
                name: sqlpassword #k8s secret name. (kubectl get secret). this is auto synced during creation and deletion of the POD
                key: sqlpassword #this must match the kv configuration in the yaml under secretObjects
          - name: SQL_SERVER
            valueFrom:
              secretKeyRef:
                name: sqlserver #k8s secret name. (kubectl get secret). this is auto synced during creation and deletion of the POD
                key: sqlserver #this must match the kv configuration in the yaml under secretObjects      
          - name: SQL_DBNAME
            value: "mydrivingDB"
          - name: CONFIG_FILES_PATH
            value: "/secrets"
          - name: PORT
            value: "80"
        resources:
          requests:
            cpu: 100m
            memory: 256Mi
          limits:
            cpu: 250m
            memory: 512Mi
        ports:
        - containerPort: 80
          name: userprofile
        volumeMounts:
          - name: secrets-store-inline
            mountPath: "/mnt/secrets-store"
            readOnly: true
