apiVersion: apps/v1
kind: Deployment
metadata:
  name: dockerhub-source-controller
  namespace: knative-sources
  labels:
    contrib.eventing.knative.dev/release: devel
    app: dockerhub-source-controller
spec:
  replicas: 1
  selector:
    matchLabels: &labels
      app: dockerhub-source-controller
  template:
    metadata:
      labels: *labels
    spec:
      # To avoid node becoming SPOF, spread the replicas to different nodes.
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - podAffinityTerm:
                labelSelector:
                  matchLabels: *labels
                topologyKey: kubernetes.io/hostname
              weight: 100

      serviceAccountName: dockerhub-source-controller
      containers:
      - name: dockerhub-source-controller
        terminationMessagePolicy: FallbackToLogsOnError
        image: ko://github.com/tom24d/eventing-dockerhub/cmd/controller
        resources:
          requests:
            cpu: 100m
            memory: 100Mi
        env:
          - name: SYSTEM_NAMESPACE
            valueFrom:
              fieldRef:
                fieldPath: metadata.namespace
          - name: POD_NAME
            valueFrom:
              fieldRef:
                fieldPath: metadata.name
          - name: CONFIG_LOGGING_NAME
            value: config-logging
          - name: CONFIG_OBSERVABILITY_NAME
            value: config-observability
          - name: CONFIG_LEADERELECTION_NAME
            value: config-leader-election-dockerhub
          - name: METRICS_DOMAIN
            value: knative.dev/sources
          - name: DH_RA_IMAGE
            value: ko://github.com/tom24d/eventing-dockerhub/cmd/receive_adapter
        securityContext:
          allowPrivilegeEscalation: false
        ports:
          - name: metrics
            containerPort: 9090
      terminationGracePeriodSeconds: 10
