apiVersion: apps/v1
kind: Deployment
metadata:
  name: controller-manager
  namespace: system
  labels:
    control-plane: controller-manager
spec:
  selector:
    matchLabels:
      control-plane: controller-manager
  replicas: 1
  template:
    metadata:
      labels:
        control-plane: controller-manager
    spec:
      containers:
        - name: manager
          args:
            - "--leader-elect"
            - "--leader-election-id=archeobot"
            - "--max-concurrent-reconciles=5"
          volumeMounts:
            - mountPath: /tmp/ansible-operator/admin/
              name: artifactory-secret
              readOnly: true
            - mountPath: /tmp/ansible-operator/rocketchat/
              name: rocketchat-webhook
              readOnly: true
            - mountPath: /tmp/ansible-operator/runner
              name: runner
          resources:
            limits:
              cpu: 3
              memory: 4Gi
            requests:
              cpu: 500m
              memory: 1Gi
          env:
            - name: ANSIBLE_GATHERING
              value: explicit
            - name: ARTIFACTORY_BASE_DNS
              value: "apps.klab.devops.gov.bc.ca"
            - name: ARTIFACTORY_URL
              value: "https://artifacts.apps.klab.devops.gov.bc.ca"
            - name: CLUSTER_NAME
              value: "klab"
            - name: WATCH_NAMESPACE
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: ANSIBLE_DEBUG_LOGS
              value: "False"
          image: controller:latest
          livenessProbe:
            httpGet:
              path: /healthz
              port: 6789
            initialDelaySeconds: 15
            periodSeconds: 20
          readinessProbe:
            httpGet:
              path: /readyz
              port: 6789
            initialDelaySeconds: 5
            periodSeconds: 10
      terminationGracePeriodSeconds: 10
      volumes:
        - name: runner
          emptyDir: {}
        - name: artifactory-secret
          secret:
            secretName: artifactory-ha-admin
        - name: rocketchat-webhook
          secret:
            secretName: rocketchat-webhook
