apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: spus.fluvio.infinyon.com
spec:
  group: fluvio.infinyon.com
  scope: Namespaced
  names:
    kind: Spu
    plural: spus
    singular: spu
  versions:
    - name: v1
      served: true
      storage:  true
      subresources:
        status: {}
      schema:
        openAPIV3Schema:
          type: object
          required: ["spec"]
          properties:
            status:
                type: object
                x-kubernetes-preserve-unknown-fields: true
            spec:
              required: ["spuId", "publicEndpoint", "privateEndpoint"]
              type: object
              properties:
                spuId:
                  type: integer
                spuType:
                  type: string
                  enum:
                    - Custom
                    - Managed              
                rack:
                  type: string
                publicEndpoint:
                  type: object
                  required: ["port"]
                  properties:
                    ingress:
                      type: array
                      items:
                        type: object
                        properties:
                          ip:
                            type: string
                            nullable: true
                          hostname:
                            type: string
                            nullable: true
                    port:
                      minimum: 1
                      maximum: 65535
                      type: integer
                    encryption:
                      type: string
                      enum:
                        - PLAINTEXT
                        - SSL
                privateEndpoint:
                  required: ["host"]
                  type: object
                  properties:
                    host:
                      type: string
                    port:
                      minimum: 1
                      maximum: 65535
                      type: integer
                    encryption:
                      type: string
                      enum:
                        - PLAINTEXT
                        - SSL
      additionalPrinterColumns:
      - name: ID
        type: integer
        description: Spu ID
        jsonPath: .spec.spuId
      - name: Status
        type: string
        description: Spu Status
        jsonPath: .status.resolution
      - name: Type
        type: string
        description: Spu Type
        jsonPath: .spec.spuType
      - name: Public Host
        type: string
        jsonPath: .spec.publicEndpoint
      - name: Private Host
        type: string
        jsonPath: .spec.privateEndpoint.host
      - name: Port
        type: integer
        description: Spu Type
        jsonPath: .spec.privateEndpoint.port
    
