apiVersion: apps/v1
kind: Deployment
metadata:
  name: mimock
  labels:
    app: mimock
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mimock
  template:
    metadata:
      labels:
        app: mimock
    spec:
      containers:
        - name: mimock-app
          image: mimock/mimock:0.0.1-alpha
          imagePullPolicy: Always
          ports:
            - containerPort: 8080
          resources:
            requests:
              cpu: "500m"
              memory: "256Mi"
            limits:
              cpu: "1000m"
              memory: "512Mi"
          envFrom:
            - configMapRef:
                name: mimock-config
            - secretRef:
                name: mimock-secrets

        - name: mimock-db
          image: postgres:13.5-alpine
          imagePullPolicy: Always
          ports:
            - containerPort: 5432
          resources:
            requests:
              cpu: "250m"
              memory: "128Mi"
            limits:
              cpu: "500m"
              memory: "256Mi"
          env:
            - name: POSTGRES_USER
              valueFrom:
                secretKeyRef:
                  name: mimock-secrets
                  key: MIMOCK_DB_USER
            - name: POSTGRES_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: mimock-secrets
                  key: MIMOCK_DB_PASSWORD
            - name: POSTGRES_DB
              valueFrom:
                configMapKeyRef:
                  name: mimock-config
                  key: MIMOCK_DB_NAME
            - name: POSTGRES_PORT
              valueFrom:
                configMapKeyRef:
                  name: mimock-config
                  key: MIMOCK_DB_PORT
