apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: espconfigs.iot.sas.com
spec:
  group: iot.sas.com
  names:
    kind: ESPConfig
    listKind: ESPConfigList
    plural: espconfigs
    singular: espconfig
  scope: Namespaced
  versions:
  - name: v1alpha1
    # Each version can be enabled/disabled by Served flag.
    served: true
    # One and only one version must be marked as the storage version.
    storage: true
    subresources:
      status: {}
    schema:  
        openAPIV3Schema:
          properties:
            apiVersion:
              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/api-conventions.md#resources'
              type: string
            kind:
              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/api-conventions.md#types-kinds'
              type: string
            metadata:
              type: object
            spec:
              properties:
                espProperties:
                  nullable: true
                  additionalProperties:
                    type: string
                  type: object
                failover:
                  type: boolean
                loadBalancePolicy:
                  type: string
                projectTemplate:
                  nullable: true
                  type: object
                  properties:
                    autoscale:
                      properties:
                        maxReplicas:
                          format: int32
                          type: integer
                        metrics:
                          items:
                            type: object
                          type: array
                        minReplicas:
                          format: int32
                          type: integer
                      required:
                      - minReplicas
                      - maxReplicas
                      - metrics
                      type: object
                    spec:
                      nullable: true
                      type: object
                      properties:
                        replicas:
                          description: number of replicas
                          format: int64
                          type: integer
                        template:
                          type: object
                          properties:
                            spec:
                              type: object
                              properties:
                                containers:
                                  type: array
                                  items:
                                    type: object
                                    properties:
                                      name:
                                        type: string
                                      image:
                                        type: string
                                    required:
                                    - name
                                    - image
                              required:
                              - containers
                          required:
                          - spec
                      required:
                      - replicas
                      - template
                loadBalancerTemplate:
                  nullable: true
                  type: object
                  properties:
                    spec:
                      nullable: true
                      type: object
                      properties:
                        replicas:
                          description: number of replicas
                          format: int64
                          type: integer     
                        template:
                          type: object
                          properties:
                            spec:
                              type: object
                              properties:
                                containers:
                                  type: array
                                  items:
                                    type: object
                                    properties:
                                      name:
                                        type: string
                                      image:
                                        type: string
                                    required:
                                    - name
                                    - image
                              required:
                              - containers
                          required:
                          - spec
                      required:
                      - replicas
                      - template
              required:
              - espProperties
              - projectTemplate
              - loadBalancerTemplate
              type: object
