# Copyright 2018 The Knative Authors
#
# 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
#
#     https://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.

# Note: The schema part of the spec is auto-generated by hack/update-schemas.sh.

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: podautoscalers.autoscaling.internal.knative.dev
  labels:
    knative.dev/crd-install: "true"
    serving.knative.dev/release: "v1.0.0"
spec:
  group: autoscaling.internal.knative.dev
  names:
    kind: PodAutoscaler
    categories:
    - knative-internal
    - autoscaling
    plural: podautoscalers
    shortNames:
    - kpa
    - pa
    singular: podautoscaler
  scope: Namespaced
  versions:
  - name: v1alpha1
    additionalPrinterColumns:
    - name: DesiredScale
      type: integer
      jsonPath: ".status.desiredScale"
    - name: ActualScale
      type: integer
      jsonPath: ".status.actualScale"
    - name: Ready
      type: string
      jsonPath: ".status.conditions[?(@.type=='Ready')].status"
    - name: Reason
      type: string
      jsonPath: ".status.conditions[?(@.type=='Ready')].reason"
    schema:
      openAPIV3Schema:
        type: object
        description: 'PodAutoscaler is a Knative abstraction that encapsulates the interface by which Knative components instantiate autoscalers.  This definition is an abstraction that may be backed by multiple definitions.  For more information, see the Knative Pluggability presentation: https://docs.google.com/presentation/d/10KWynvAJYuOEWy69VBa6bHJVCqIsz1TNdEKosNvcpPY/edit'
        properties:
          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'
          metadata:
            type: object
          spec:
            type: object
            description: Spec holds the desired state of the PodAutoscaler (from the client).
            properties:
              containerConcurrency:
                type: integer
                description: ContainerConcurrency specifies the maximum allowed in-flight (concurrent) requests per container of the Revision. Defaults to `0` which means unlimited concurrency.
                format: int64
              protocolType:
                type: string
                description: The application-layer protocol. Matches `ProtocolType` inferred from the revision spec.
              reachability:
                type: string
                description: Reachability specifies whether or not the `ScaleTargetRef` can be reached (ie. has a route). Defaults to `ReachabilityUnknown`
              scaleTargetRef:
                type: object
                description: ScaleTargetRef defines the /scale-able resource that this PodAutoscaler is responsible for quickly right-sizing.
                properties:
                  name:
                    type: string
                    description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
                  apiVersion:
                    type: string
                    description: API version of the referent.
                  kind:
                    type: string
                    description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
            required:
            - protocolType
            - scaleTargetRef
          status:
            type: object
            description: Status communicates the observed state of the PodAutoscaler (from the controller).
            properties:
              annotations:
                type: object
                additionalProperties:
                  type: string
                description: Annotations is additional Status fields for the Resource to save some additional State as well as convey more information to the user. This is roughly akin to Annotations on any k8s resource, just the reconciler conveying richer information outwards.
              serviceName:
                type: string
                description: ServiceName is the K8s Service name that serves the revision, scaled by this PA. The service is created and owned by the ServerlessService object owned by this PA.
              actualScale:
                type: integer
                description: ActualScale shows the actual number of replicas for the revision.
                format: int32
              conditions:
                type: array
                description: Conditions the latest available observations of a resource's current state.
                items:
                  type: object
                  description: 'Condition defines a readiness condition for a Knative resource. See: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties'
                  properties:
                    type:
                      type: string
                      description: Type of condition.
                    status:
                      type: string
                      description: Status of the condition, one of True, False, Unknown.
                    lastTransitionTime:
                      type: string
                      description: LastTransitionTime is the last time the condition transitioned from one status to another. We use VolatileTime in place of metav1.Time to exclude this from creating equality.Semantic differences (all other things held constant).
                      format: date-time
                    message:
                      type: string
                      description: A human readable message indicating details about the transition.
                    reason:
                      type: string
                      description: The reason for the condition's last transition.
                    severity:
                      type: string
                      description: Severity with which to treat failures of this type of condition. When this is not specified, it defaults to Error.
                  required:
                  - status
                  - type
              desiredScale:
                type: integer
                description: DesiredScale shows the current desired number of replicas for the revision.
                format: int32
              metricsServiceName:
                type: string
                description: MetricsServiceName is the K8s Service name that provides revision metrics. The service is managed by the PA object.
              observedGeneration:
                type: integer
                description: ObservedGeneration is the 'Generation' of the Service that was last processed by the controller.
                format: int64
            required:
            - metricsServiceName
            - serviceName
    served: true
    storage: true
    subresources:
      status: {}
