# Copyright 2020-2021 TriggerMesh Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: event-sources-controller
  namespace: triggermesh

spec:
  replicas: 1
  selector:
    matchLabels:
      app: event-sources-controller

  template:
    metadata:
      labels:
        app: event-sources-controller

    spec:
      serviceAccountName: event-sources-controller

      containers:
      - name: controller
        terminationMessagePolicy: FallbackToLogsOnError
        image: ko://github.com/triggermesh/event-sources/cmd/event-sources-controller

        resources:
          requests:
            cpu: 20m
            memory: 20Mi

        env:
        - name: SYSTEM_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        # Logging/observability configuration
        - name: CONFIG_LOGGING_NAME
          value: config-logging
        - name: CONFIG_OBSERVABILITY_NAME
          value: config-observability
        - name: METRICS_DOMAIN
          value: triggermesh.io/sources
        # Source adapters
        - name: AZUREEVENTHUBSOURCE_IMAGE
          value: ko://github.com/triggermesh/event-sources/cmd/azureeventhubsource-adapter
        - name: AZUREQUEUESTORAGESOURCE_IMAGE
          value: ko://github.com/triggermesh/event-sources/cmd/azurequeuestoragesource-adapter
        - name: AZURESERVICEBUSQUEUESOURCE_IMAGE
          value: ko://github.com/triggermesh/event-sources/cmd/azureservicebusqueuesource-adapter
        - name: GOOGLECLOUDPUBSUBSOURCE_IMAGE
          value: ko://github.com/triggermesh/event-sources/cmd/googlecloudpubsubsource-adapter
        - name: OCIMETRICSSOURCE_IMAGE
          value: ko://github.com/triggermesh/event-sources/cmd/ocimetricssource-adapter
        - name: SALESFORCESOURCE_IMAGE
          value: ko://github.com/triggermesh/event-sources/cmd/salesforcesource-adapter
        - name: TWILIOSOURCE_IMAGE
          value: ko://github.com/triggermesh/event-sources/cmd/twiliosource-adapter

        securityContext:
          allowPrivilegeEscalation: false

        ports:
        - name: metrics
          containerPort: 9090
        - name: profiling
          containerPort: 8008
