apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: staple
  name: staple-app
  labels:
    app: staple
spec:
  replicas: 1
  selector:
    matchLabels:
      app: staple
  template:
    metadata:
      labels:
        app: staple
        app.kubernetes.io/name: staple
        app.kubernetes.io/instance: staple
    spec:
      containers:
      - name: staple
        image: skarlso/staple:v0.1.0
        imagePullPolicy: IfNotPresent
        resources:
          requests:
            memory: "500Mi"
            cpu: "250m"
          limits:
            memory: "1000Mi"
            cpu: "500m"
        env:
          - name: POD_NAMESPACE
            valueFrom:
              fieldRef:
                fieldPath: metadata.namespace
          - name: DB_PASSWORD
            valueFrom:
              secretKeyRef:
                name: staple-db-password
                key: POSTGRES_PASSWORD
          - name: MG_DOMAIN
            valueFrom:
              secretKeyRef:
                name: staple-mg-creds
                key: MG_DOMAIN
          - name: MG_API_KEY
            valueFrom:
              secretKeyRef:
                name: staple-mg-creds
                key: MG_API_KEY
        args:
          - --staple-db-hostname=staple-db-service.cronohub.svc.cluster.local:5432
          - --staple-db-username=staple
          - --staple-db-database=staple
          - --staple-db-password=$(DB_PASSWORD)
          - --mg-domain=$(MG_DOMAIN)
          - --mg-api-key=$(MG_API_KEY)
        ports:
        - name: staple-port
          containerPort: 9998
