apiVersion: apps/v1
kind: Deployment
metadata:
  name: controller-manager
  namespace: default
  labels:
    control-plane: coherence
    app.kubernetes.io/name: coherence-operator
    app.kubernetes.io/instance: coherence-operator-manager
    app.kubernetes.io/version: "3.2.6"
    app.kubernetes.io/component: manager
    app.kubernetes.io/part-of: coherence-operator
spec:
  selector:
    matchLabels:
      control-plane: coherence
  replicas: 1
  template:
    metadata:
      labels:
        control-plane: coherence
        app.kubernetes.io/name: coherence-operator
        app.kubernetes.io/instance: coherence-operator-manager
        app.kubernetes.io/version: "3.2.6"
        app.kubernetes.io/component: manager
        app.kubernetes.io/part-of: coherence-operator
    spec:
      serviceAccountName: service-account
      terminationGracePeriodSeconds: 10
      containers:
      - name: manager
        image: controller:latest
        ports:
        - containerPort: 8000
          name: operator
          protocol: TCP
        - containerPort: 9443
          name: webhook-server
          protocol: TCP
        - containerPort: 8080
          name: metrics-server
          protocol: TCP
        - containerPort: 8088
          name: health-server
          protocol: TCP
        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: $(WEBHOOK_SERVICE_NAME)
          - name: WEBHOOK_SECRET
            value: $(WEBHOOK_SECRET_NAME)
          - name: SERVICE_NAME
            value: $(REST_SERVICE_NAME)
        volumeMounts:
        - mountPath: /tmp/k8s-webhook-server/serving-certs
          name: cert
          readOnly: true
        readinessProbe:
          tcpSocket:
            port: metrics-server
          initialDelaySeconds: 10
          periodSeconds: 10
          failureThreshold: 3
      volumes:
      - name: cert
        secret:
          defaultMode: 420
          secretName: coherence-webhook-server-cert
          optional: true
