apiVersion: apps/v1
kind: Deployment
metadata:
  name: trips-deployment
  namespace: api
  labels:
    app: trips
    component: trips
spec:
  selector:
    matchLabels:
      app: trips
      component: trips
  replicas: 2 # tells deployment to run 2 pods matching the template
  template:
    metadata:
      labels:
        app: trips
        component: trips
    spec:
      containers:
      - name: trips
        image: registryucj0309.azurecr.io/tripinsights/trips:1.0
        ports:
        - containerPort: 80
        volumeMounts:
        - name: secrets-store-inline
          mountPath: "/mnt/secrets-store"
          readOnly: true
        env:
        - name: SQL_USER
          valueFrom:
            secretKeyRef:
              name: sql-server-user
              key: user 
        - name: SQL_SERVER
          valueFrom:
            secretKeyRef:
              name: sql-server-server
              key: server 
        - name: SQL_PASSWORD
          valueFrom:
            secretKeyRef:
              name: sql-server-pwd
              key: pwd 
      volumes:
        - name: secrets-store-inline
          csi:
            driver: secrets-store.csi.k8s.io
            readOnly: true
            volumeAttributes:
              secretProviderClass: azure-kvname-user-msi   
      nodeSelector:
        kubernetes.io/os: linux