apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: benchmarks.theodolite.com
spec:
  group: theodolite.com
  names:
    kind: benchmark
    plural: benchmarks
    shortNames:
      - bench
  versions:
  - name: v1
    served: true
    storage: true
    schema:
      openAPIV3Schema:
        type: object
        required: ["spec"]
        properties:
          spec:
            type: object
            required: ["appResource", "loadGenResource", "resourceTypes", "loadTypes", "kafkaConfig"]
            properties:
              name:
                description: This field exists only for technical reasons and should not be set by the user. The value of the field will be overwritten.
                type: string
              appResource:
                description: A list of file names that reference Kubernetes resources that are deployed on the cluster for the system under test (SUT).
                type: array
                minItems: 1
                items:
                  type: string
              loadGenResource:
                description:  A list of file names that reference Kubernetes resources that are deployed on the cluster for the load generator.
                type: array
                minItems: 1
                items:
                  type: string
              resourceTypes:
                description: A list of resource types that can be scaled for this `benchmark` resource. For each resource type the concrete values are defined in the `execution` object.
                type: array
                minItems: 1
                items:
                  type: object
                  required: ["typeName", "patchers"]
                  properties:
                    typeName:
                      description: Name of the resource type.
                      type: string
                    patchers:
                      description: List of patchers used to scale this resource type.
                      examples: test test test
                      type: array
                      minItems: 1
                      items:
                        type: object
                        required: ["type", "resource"]
                        properties:
                          type:
                            description: Type of the patcher.
                            type: string
                            default: ""
                          resource:
                            description: Specifies the Kubernetes resource to be patched.
                            type: string
                            default: ""
                          properties:
                            description: (Optional) Patcher specific additional arguments.
                            type: object
                            additionalProperties: true
                            x-kubernetes-map-type: "granular"
                            default: {}
              loadTypes:
                description: A list of load types that can be scaled for this benchmark. For each load type the concrete values are defined in the execution object.
                type: array
                minItems: 1
                items:
                  type: object
                  required: ["typeName","patchers"]
                  properties:
                    typeName:
                      description: Name of the load type.
                      type: string
                    patchers:
                      description: List of patchers used to scale this resource type.
                      type: array
                      minItems: 1
                      items:
                        type: object
                        required: ["type", "resource"]
                        properties:
                          type:
                            description: Type of the Patcher.
                            type: string
                            default: ""
                          resource:
                            description: Specifies the Kubernetes resource to be patched.
                            type: string
                            default: ""
                          properties:
                            description: (Optional) Patcher specific additional arguments.
                            type: object
                            additionalProperties: true
                            x-kubernetes-map-type: "granular"
                            default: {}
              kafkaConfig:
                description: Contains the Kafka configuration.
                type: object
                required: ["bootstrapServer", "topics"]
                properties:
                  bootstrapServer:
                    description: The bootstrap servers connection string.
                    type: string
                  topics:
                    description: List of topics to be created for each experiment. Alternative theodolite offers the possibility to remove certain topics after each experiment.
                    type: array
                    minItems: 1
                    items:
                      type: object
                      required: ["name"]
                      properties:
                        name:
                          description: The name of the topic.
                          type: string
                          default: ""
                        numPartitions:
                          description: The number of partitions of the topic.
                          type: integer
                          default: 0
                        replicationFactor:
                          description: The replication factor of the topic.
                          type: integer
                          default: 0
                        removeOnly:
                          description: Determines if this topic should only be deleted after each experiement. For removeOnly topics the name can be a RegEx describing the topic.
                          type: boolean
                          default: false
    additionalPrinterColumns:
    - name: Age
      type: date
      jsonPath: .metadata.creationTimestamp
    subresources:
      status: {}
  scope: Namespaced