apiVersion: apps/v1
kind: Deployment
metadata:
  name: controller-manager
  namespace: default
  labels:
    control-plane: coherence
spec:
  selector:
    matchLabels:
      control-plane: coherence
  replicas: 1
  template:
    metadata:
      labels:
        control-plane: coherence
    spec:
      terminationGracePeriodSeconds: 10
      containers:
      - name: manager
        image: controller:latest
        ports:
        - containerPort: 9443
          name: webhook-server
          protocol: TCP
        command:
          - /manager
        args:
          - --enable-leader-election
        envFrom:
          - configMapRef:
              name: env-vars
              optional: true
        env:
          - name: OPERATOR_NAMESPACE
            valueFrom:
              fieldRef:
                fieldPath: metadata.namespace
          - name: OPERATOR_NAME
            valueFrom:
              fieldRef:
                fieldPath: metadata.name
          - name: WEBHOOK_SERVICE
            value: $(SERVICE_NAME)
          - name: WEBHOOK_SECRET
            value: coherence-webhook-server-cert
        volumeMounts:
        - mountPath: /tmp/k8s-webhook-server/serving-certs
          name: cert
          readOnly: true
      volumes:
      - name: cert
        secret:
          defaultMode: 420
          secretName: coherence-webhook-server-cert
