apiVersion: apps/v1
kind: Deployment
metadata:
  name: order-api
spec:
  replicas: 1
  selector:
    matchLabels:
      app: order-api
  template:
    metadata:
      labels:
        app: order-api
    spec:
      containers:
      - image: order-api # must much from ./kustomization.yaml -> images[0].name
        imagePullPolicy: IfNotPresent
        name: order-api
        ports:
          - containerPort: 8090
        env:
        - name: SERVER_SERVLET_CONTEXT_PATH
          value: /order
        - name: AUTH_URL 
          valueFrom:
            configMapKeyRef:
              name: order-api
              key: auth.url 
        - name: BASKET_URL
          valueFrom:
            configMapKeyRef:
              name: order-api
              key: basket.url
        - name: SPRING_DATASOURCE_URL
          valueFrom:
            configMapKeyRef:
              name: order-api
              key: datasource.url
        - name: SPRING_DATASOURCE_USERNAME
          valueFrom:
            secretKeyRef:
              name: order-api
              key: db.username
        - name: SPRING_DATASOURCE_PASSWORD
          valueFrom:
            secretKeyRef:
              name: order-api
              key: db.password
        readinessProbe:
          httpGet:
            path: /order/health
            port: 8090
          initialDelaySeconds: 30
          timeoutSeconds: 3
          periodSeconds: 30
          successThreshold: 1
          failureThreshold: 5
        livenessProbe:
          httpGet:
            path: /order/health
            port: 8090
          initialDelaySeconds: 60
          timeoutSeconds: 3
          periodSeconds: 30
          successThreshold: 1
          failureThreshold: 5
        resources:
          requests:
            memory: "128Mi"
            cpu: "300m"
          limits:
            memory: "256Mi"
            cpu: "400m"