# Copyright 2021 Google LLC
#
# 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:
  labels:
    apigee.cloud.google.com/platform: apigee
    control-plane: controller-manager
  name: apigee-controller-manager
  namespace: apigee-system
spec:
  replicas: 1
  selector:
    matchLabels:
      control-plane: controller-manager
  template:
    metadata:
      labels:
        apigee.cloud.google.com/platform: apigee
        app: apigee-controller
        control-plane: controller-manager
        revision: "000"
    spec:
      securityContext:
        runAsNonRoot: true
        runAsGroup: 998
        runAsUser: 999
      containers:
      - args:
        - --secure-listen-address=0.0.0.0:8443
        - --upstream=http://127.0.0.1:8080/
        - --logtostderr=true
        - --v=10
        image: gcr.io/apigee-release/hybrid/apigee-kube-rbac-proxy:v0.8.0
        imagePullPolicy: IfNotPresent
        name: kube-rbac-proxy
        ports:
        - containerPort: 8443
          name: https
          protocol: TCP
      - args:
        - --metrics-addr=127.0.0.1:8080
        - --enable-leader-election
        - --apigee-runtime-type=hybrid
        - --log-level=info
        - --enable-webhooks=true
        - --enable-controllers=true
        - --enable-api-client=true
        command:
        - /manager
        image: gcr.io/apigee-release/hybrid/apigee-operators:1.6.3
        imagePullPolicy: IfNotPresent
        name: manager
        ports:
        - containerPort: 9443
          name: webhook-server
          protocol: TCP
        resources:
          limits:
            cpu: 1000m
            memory: 1024Mi
          requests:
            cpu: 100m
            memory: 512Mi
        volumeMounts:
        - name: tmpfs
          mountPath: /tmp
        - mountPath: /tmp/k8s-webhook-server/serving-certs
          name: cert
          readOnly: true
      terminationGracePeriodSeconds: 10
      volumes:
      - name: tmpfs
        emptyDir: {}
      - name: cert
        secret:
          defaultMode: 420
          secretName: webhook-server-cert
