apiVersion: apps/v1
kind: Deployment
metadata:
  name: workflows-controller
  namespace: workflows-system
spec:
  replicas: 1
  selector:
    matchLabels:
      app: workflows-controller
  template:
    metadata:
      labels:
        app: workflows-controller
    spec:
      serviceAccountName: controller
      containers:
      - name: controller
        # This is the Go import path for the binary that is containerized
        # and substituted here.
        image: ko://github.com/nubank/workflows/cmd/controller
        resources:
          requests:
            cpu: 500m
            memory: 512Mi
          limits:
            cpu: 500m
            memory: 512Mi
        ports:
        - name: metrics
          containerPort: 9090
        env:
        - name: GITHUB_APP_ID
          valueFrom:
            configMapKeyRef:
              name: config-github-app
              key: app-id
        - name: GITHUB_INSTALLATION_ID
          valueFrom:
            configMapKeyRef:
              name: config-github-app
              key: installation-id
        - name: SYSTEM_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        - name: CONFIG_LOGGING_NAME
          value: config-logging
        - name: CONFIG_OBSERVABILITY_NAME
          value: config-observability
        - name: METRICS_DOMAIN
          value: workflows.dev/workflows

        volumeMounts:
        - name: github-app-private-key
          mountPath: /var/run/secrets/github

      volumes:
        - name: github-app-private-key
          secret:
            secretName: github-app-private-key
