# Copyright 2020 VMware, Inc.
# SPDX-License-Identifier: Apache-2.0

apiVersion: apps/v1
kind: Deployment
metadata:
  name: webhook
  namespace: vmware-sources
  labels:
    sources.tanzu.vmware.com/release: devel
spec:
  replicas: 1
  selector:
    matchLabels:
      app: webhook
      role: webhook
  template:
    metadata:
      labels:
        app: webhook
        role: webhook
        sources.tanzu.vmware.com/release: devel
    spec:
      serviceAccountName: controller
      containers:
      - name: webhook
        # This is the Go import path for the binary that is containerized
        # and substituted here.
        image: ko://github.com/vmware-tanzu/sources-for-knative/cmd/sources-for-knative-controller
        resources:
          # Request 2x what we saw running e2e
          requests:
            cpu: 20m
            memory: 20Mi
          # Limit to 10x the request (20x the observed peak during e2e)
          limits:
            cpu: 200m
            memory: 200Mi
        env:
        - name: VSPHERE_ADAPTER
          value: ko://github.com/vmware-tanzu/sources-for-knative/cmd/sources-for-knative-adapter
        - name: SYSTEM_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        - name: CONFIG_LOGGING_NAME
          value: config-logging
        - name: METRICS_DOMAIN
          value: tanzu.vmware.com/sources
        - name: WEBHOOK_NAME
          value: webhook

        readinessProbe: &probe
          periodSeconds: 1
          httpGet:
            scheme: HTTPS
            port: 8443
            httpHeaders:
            - name: k-kubelet-probe
              value: "webhook"
        livenessProbe: *probe
