apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: autoscalers.scaler.k8s.do
spec:
  group: scaler.k8s.do
  names:
    kind: AutoScaler
    listKind: AutoScalerList
    plural: autoscalers
    singular: autoscaler
    categories:
    - all
  scope: Namespaced
  versions:
  - name: v1
    served: true
    storage: true
    subresources:
      status: {}
    # additionalPrinterColumns:
    # - jsonPath: .status.opengaussStatus
    #   name: Status
    #   type: string
    #   description: Current sync status of opengauss resource
    schema:
      openAPIV3Schema:
        type: object
        required:
          - kind
          - apiVersion
          - spec
        properties:
          kind:
            type: string
            enum:
              - AutoScaler
          apiVersion:
            type: string
            enum:
              - scaler.k8s.do/v1
          spec:
            type: object
            required:
              - cluster
            properties:
              cluster:
                type: object
                required:
                - name
                - namespace
                properties:
                  name:
                    type: string
                  namespace:
                    type: string
              master:
                type: object
                required:
                - spec
                properties:
                  spec:
                    type: object
                    required:
                    - maxReplicas
                    properties:
                      externalEndpoint:
                        properties:
                          host:
                            type: string
                          path:
                            type: string
                          port:
                            format: int32
                            type: integer
                          tlsSecret:
                            properties:
                              name:
                                type: string
                              namespace:
                                type: string
                            required:
                            - name
                            - namespace
                            type: object
                        required:
                        - host
                        - port
                        - path
                        type: object
                      maxReplicas:
                        format: int32
                        type: integer
                      metrics:
                        items:
                          type: string
                        type: array
                      metricsTimeDuration:
                        type: string
                      minReplicas:
                        format: int32
                        type: integer
                      maxReplicas:
                        format: int32
                        type: integer
                      scaleInIntervalSeconds:
                        format: int32
                        type: integer
                      scaleOutIntervalSeconds:
                        format: int32
                        type: integer
              worker:
                type: object
                required:
                - spec
                properties:
                  spec:
                    type: object
                    required:
                    - maxReplicas
                    properties:
                      externalEndpoint:
                        properties:
                          host:
                            type: string
                          path:
                            type: string
                          port:
                            format: int32
                            type: integer
                          tlsSecret:
                            properties:
                              name:
                                type: string
                              namespace:
                                type: string
                            required:
                            - name
                            - namespace
                            type: object
                        required:
                        - host
                        - port
                        - path
                        type: object
                      maxReplicas:
                        format: int32
                        type: integer
                      metrics:
                        items:
                          type: string
                        type: array
                      metricsTimeDuration:
                        type: string
                      minReplicas:
                        format: int32
                        type: integer
                      maxReplicas:
                        format: int32
                        type: integer
                      scaleInIntervalSeconds:
                        format: int32
                        type: integer
                      scaleOutIntervalSeconds:
                        format: int32
                        type: integer

          status:
            type: object
            additionalProperties:
              type: string