
# Create Contoso Supermarket Point Of Sale Service
apiVersion: v1
kind: Service
metadata:
  name: contosopos
  namespace: {{ .Release.Namespace }}
  labels:
    app: contosopos
spec:
  selector:
    app: contosopos
  ports:
  - name: http
    port: 5000
    targetPort: 5000
  type: LoadBalancer
---
# Create Contoso Supermarket Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
  name: contosopos
  namespace: {{ .Release.Namespace }}
  labels:
    app: contosopos
spec:
  replicas: 1
  selector:
    matchLabels:
      app: contosopos
  template:
    metadata:
      labels:
        app: contosopos
    spec:
      containers:
        - name: contosopos
          image: "{{ .Values.acr_name }}.azurecr.io/{{ .Values.branch_name}}/contoso-supermarket/pos:{{ .Values.image_tag}}"
          env:
            - name: SQL_HOST
              value: contosodb
            - name: SQL_USERNAME
              value: {{ .Values.postgres.username }}
            - name: SQL_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: postgrespw
                  key: POSTGRES_PASSWORD
            - name: SQL_DATABASE
              value: {{ .Values.postgres.database }}
            - name: HEAD_TITLE
              value : {{ .Values.point_of_sale.title }}
            - name: NEW_CATEGORY
              value: "{{ .Values.point_of_sale.new_category }}"
            - name: STORE_ID
              value: "{{ required "A Store ID is required!" .Values.point_of_sale.store_id }}"
            - name: STORE_LOCATION
              value: "{{ required "A Store Location is required!" .Values.point_of_sale.store_location }}"
            - name: HOLIDAY_BANNER
              value: "{{ .Values.point_of_sale.holiday_banner }}"
          ports:
            - containerPort: 5000
      imagePullSecrets:
        - name: acr-secret