kind: CustomResourceDefinition
apiVersion: apiextensions.k8s.io/v1
metadata:
  annotations:
    polaris-slo-cloud.github.io/schema-gen-version: 0.2.0-beta.19
  name: costefficiencyslomappings.slo.polaris-slo-cloud.github.io
spec:
  group: slo.polaris-slo-cloud.github.io
  names:
    kind: CostEfficiencySloMapping
    listKind: CostEfficiencySloMappingList
    singular: costefficiencyslomapping
    plural: costefficiencyslomappings
  scope: Namespaced
  versions:
    - name: v1
      served: true
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          required:
            - metadata
            - spec
            - apiVersion
            - kind
          description: >-
            The Cost Efficiency SLO is based on the *cost efficiency* of a REST
            service.


            The cost efficiency of a REST service is calculated as: (number of
            requests per second served faster than a configured threshold)
            divided by (total cost of the service).
          properties:
            metadata:
              type: object
            spec:
              type: object
              required:
                - elasticityStrategy
                - sloConfig
                - targetRef
              description: The spec for a `CostEfficiencySloMapping`.
              properties:
                targetRef:
                  type: object
                  required:
                    - kind
                    - name
                    - apiVersion
                  properties:
                    kind:
                      type: string
                      description: >-
                        Kind is a string value representing the REST resource
                        this object represents. Servers may infer this from the
                        endpoint the client submits requests to. Cannot be
                        updated. In CamelCase. More info:
                        https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
                    name:
                      type: string
                      description: The name of the instance.
                    apiVersion:
                      type: string
                      description: >-
                        APIVersion defines the versioned schema of this
                        representation of an object. Servers should convert
                        recognized schemas to the latest internal value, and may
                        reject unrecognized values. More info:
                        https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
                elasticityStrategy:
                  type: object
                  required:
                    - kind
                    - apiVersion
                  description: Identifies an elasticity strategy kind/type.
                  properties:
                    kind:
                      type: string
                      description: >-
                        Kind is a string value representing the REST resource
                        this object represents. Servers may infer this from the
                        endpoint the client submits requests to. Cannot be
                        updated. In CamelCase. More info:
                        https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
                    apiVersion:
                      type: string
                      description: >-
                        APIVersion defines the versioned schema of this
                        representation of an object. Servers should convert
                        recognized schemas to the latest internal value, and may
                        reject unrecognized values. More info:
                        https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
                stabilizationWindow:
                  type: object
                  description: >-
                    StabilizationWindow allows configuring the period of time
                    that an elasticity strategy controller will wait after
                    applying the strategy once, before applying it again (if the
                    SLO is still violated), to avoid unnecessary scaling.


                    For example, suppose that ScaleUpSeconds = 180 and a
                    horizontal elasticity strategy scales out at time `t` due to
                    an SLO violation. At time `t + 20 seconds` the SLO's
                    evaluation still results in a violation, but the elasticity
                    strategy does not scale again, because the stabilization
                    window for scaling up/out has not yet passed. If the SLO
                    evaluation at `t + 200 seconds` still results in a
                    violation, the controller will scale again.
                  properties:
                    scaleUpSeconds:
                      type: integer
                      description: >-
                        The number of seconds after the previous scaling
                        operation to wait before an elasticity action that
                        increases resources (e.g., scale up/out) or an
                        equivalent configuration change can be issued due to an
                        SLO violation.
                      minimum: 0
                      default: 60
                      format: int64
                    scaleDownSeconds:
                      type: integer
                      description: >-
                        The number of seconds after the previous scaling
                        operation to wait before an elasticity action that
                        decreases resources (e.g., scale down/in) or an
                        equivalent configuration change can be issued due to an
                        SLO violation.
                      minimum: 0
                      default: 300
                      format: int64
                sloConfig:
                  type: object
                  properties:
                    responseTimeThresholdMs:
                      type: integer
                      enum:
                        - 10
                        - 25
                        - 50
                        - 100
                        - 250
                        - 500
                        - 1000
                        - 2500
                        - 5000
                        - 10000
                      description: >-
                        The response time threshold in milliseconds, below which
                        all requests should be answered, i.e., ideally all
                        responses should be faster than this value.
                      format: int64
                    targetCostEfficiency:
                      type: integer
                      description: The desired cost efficiency value.
                      minimum: 0
                      format: int64
                    minRequestsPercentile:
                      type: integer
                      description: >-
                        The minimum percentile of requests that should be faster
                        than `responseTimeThresholdMs`.


                        A low cost efficiency value can indicate either a) that
                        the system cannot handle a very high load or, b) that
                        the load is very low and the system has too many
                        resources. The `minRequestsPercentile` is used to
                        distinguish these two cases.


                        If the cost efficiency is low and the number of requests
                        faster than the threshold is below this percentile, we
                        know that we are dealing with case a), i.e., the SLO
                        compliance percentage will be above 100% (e.g., more
                        resources are needed).


                        Whereas, if the number of requests faster than the
                        threshold is above this percentile, we know that we are
                        dealing with case b), i.e., the SLO compliance
                        percentage will be below 100% (e.g., resources can be
                        reduced).
                      default: 90
                      format: int64
                  required:
                    - responseTimeThresholdMs
                    - targetCostEfficiency
                  description: The configuration of a Cost Efficiency SLO Mapping.
                staticElasticityStrategyConfig:
                  type: object
                  description: Convenience type for a map object with string keys.
            apiVersion:
              type: string
              description: >-
                APIVersion defines the versioned schema of this representation
                of an object. Servers should convert recognized schemas to the
                latest internal value, and may reject unrecognized values. More
                info:
                https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
            kind:
              type: string
              description: >-
                Kind is a string value representing the REST resource this
                object represents. Servers may infer this from the endpoint the
                client submits requests to. Cannot be updated. In CamelCase.
                More info:
                https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
