apiVersion: apps/v1
kind: Deployment
metadata:
  name: lifecycle-operator
  namespace: system
  labels:
    app.kubernetes.io/part-of: keptn
    app.kubernetes.io/component: lifecycle-operator
    control-plane: lifecycle-operator
    keptn.sh/inject-cert: "true"
spec:
  selector:
    matchLabels:
      control-plane: lifecycle-operator
  replicas: 1
  template:
    metadata:
      annotations:
        kubectl.kubernetes.io/default-container: lifecycle-operator
        metrics.dynatrace.com/scrape: 'true'
        metrics.dynatrace.com/port: '2222'
      labels:
        control-plane: lifecycle-operator
    spec:
      securityContext:
        runAsNonRoot: true
        # TODO(user): For common cases that do not require escalating privileges
        # it is recommended to ensure that all your Pods/Containers are restrictive.
        # More info: https://kubernetes.io/docs/concepts/security/pod-security-standards/#restricted
        # Please uncomment the following code if your project does NOT have to work on old Kubernetes
        # versions < 1.19 or on vendors versions which do NOT support this field by default (i.e. Openshift < 4.11 ).
        # seccompProfile:
        #   type: RuntimeDefault
      containers:
        - command:
            - /manager
          args:
            - --leader-elect
          image: controller:latest
          name: lifecycle-operator
          ports:
            - containerPort: 9443
              name: webhook-server
              protocol: TCP
            - name: metrics
              containerPort: 2222
              protocol: TCP
          imagePullPolicy: Always
          env:
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: FUNCTION_RUNNER_IMAGE
              value: ghcr.io/keptn/deno-runtime:v3.0.1
            - name: PYTHON_RUNNER_IMAGE
              value: ghcr.io/keptn/python-runtime:v1.0.8
            - name: KEPTN_APP_CONTROLLER_LOG_LEVEL
              value: "0"
            - name: KEPTN_APP_CREATION_REQUEST_CONTROLLER_LOG_LEVEL
              value: "0"
            - name: KEPTN_APP_VERSION_CONTROLLER_LOG_LEVEL
              value: "0"
            - name: KEPTN_EVALUATION_CONTROLLER_LOG_LEVEL
              value: "0"
            - name: KEPTN_TASK_CONTROLLER_LOG_LEVEL
              value: "0"
            - name: KEPTN_TASK_DEFINITION_CONTROLLER_LOG_LEVEL
              value: "0"
            - name: KEPTN_WORKLOAD_CONTROLLER_LOG_LEVEL
              value: "0"
            - name: KEPTN_WORKLOAD_VERSION_CONTROLLER_LOG_LEVEL
              value: "0"
            - name: KEPTN_WORKLOAD_INSTANCE_CONTROLLER_LOG_LEVEL
              value: "0"
            - name: OPTIONS_CONTROLLER_LOG_LEVEL
              value: "0"
            - name: PROMOTION_TASKS_ENABLED
              value: "false"
            - name: CERT_MANAGER_ENABLED
              value: "true"
          securityContext:
            seccompProfile:
              type: RuntimeDefault
            privileged: false
            allowPrivilegeEscalation: false
            runAsNonRoot: true
            runAsUser: 65532
            runAsGroup: 65532
            capabilities:
              drop:
                - "ALL"
          volumeMounts:
            - name: keptn-certs
              mountPath: /tmp/webhook/certs/
          livenessProbe:
            httpGet:
              path: /healthz
              port: 8081
            initialDelaySeconds: 15
            periodSeconds: 20
          readinessProbe:
            httpGet:
              path: /readyz
              port: 8081
            initialDelaySeconds: 5
            periodSeconds: 10
          # TODO(user): Configure the resources accordingly based on the project requirements.
          # More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
          resources:
            limits:
              cpu: 500m
              memory: 128Mi
            requests:
              cpu: 5m
              memory: 64Mi
      serviceAccountName: lifecycle-operator
      terminationGracePeriodSeconds: 10
      hostNetwork: false
      volumes:
        - name: keptn-certs
          secret:
            secretName: keptn-certs
