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: ["sut", "loadGenerator", "resourceTypes", "loadTypes"]
            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
                default: ""
              infrastructure:
                description: (Optional) A list of file names that reference Kubernetes resources that are deployed on the cluster to create the required infrastructure.
                type: object
                default: {}
                properties:
                  resources:
                    type: array
                    default: []
                    items:
                      type: object
                      oneOf:
                        - required: [ configMap ]
                        - required: [ fileSystem ]
                      properties:
                        configMap:
                          description: The configMap resourceSet loads the Kubernetes manifests from an Kubernetes configMap.
                          type: object
                          properties:
                            name:
                              description: The name of the configMap
                              type: string
                            files:
                              description: (Optional) Specifies which files from the configMap should be loaded. If this field is not set, all files are loaded.
                              type: array
                              items:
                                type: string
                        fileSystem:
                          description: The fileSystem resourceSet loads the Kubernetes manifests from the filesystem.
                          type: object
                          properties:
                            path:
                              description: The path to the folder which contains the Kubernetes manifests files.
                              type: string
                            files:
                              description: (Optional) Specifies which files from the configMap should be loaded. If this field is not set, all files are loaded.
                              type: array
                              items:
                                type: string
                  beforeActions:
                    type: array
                    default: []
                    description: Infrastructure before actions are executed before the infrastructure is set up.
                    items:
                      type: object
                      properties:
                        selector:
                          type: object
                          description: The selector specifies which resource should be selected for the execution of the command.
                          properties:
                            pod:
                              type: object
                              description: Specifies the pod.
                              properties:
                                matchLabels:
                                  type: object
                                  description: The matchLabels of the desired pod.
                                  additionalProperties: true
                                  x-kubernetes-map-type: "granular"
                                  default: { }
                            container:
                              description: Specifies the container.
                              default: ""
                              type: string
                        exec:
                          type: object
                          description: Specifies command to be executed.
                          properties:
                            command:
                              type: array
                              description: The command to be executed as string array.
                              items:
                                type: string
                            timeoutSeconds:
                              description: Specifies the timeout (in seconds) for the specified command.
                              type: integer
                  afterActions:
                    type: array
                    default: []
                    description: Infrastructure after actions are executed after the teardown of the infrastructure.
                    items:
                      type: object
                      properties:
                        selector:
                          type: object
                          description: The selector specifies which resource should be selected for the execution of the command.
                          properties:
                            pod:
                              type: object
                              description: Specifies the pod.
                              properties:
                                matchLabels:
                                  type: object
                                  description: The matchLabels of the desired pod.
                                  additionalProperties: true
                                  x-kubernetes-map-type: "granular"
                                  default: { }
                            container:
                              description: Specifies the container.
                              default: ""
                              type: string
                        exec:
                          type: object
                          description: Specifies command to be executed.
                          properties:
                            command:
                              type: array
                              description: The command to be executed as string array.
                              items:
                                type: string
                            timeoutSeconds:
                              description: Specifies the timeout (in seconds) for the specified command.
                              type: integer
              sut:
                description: The appResourceSets specifies all Kubernetes resources required to start the sut. A resourceSet can be either a configMap resourceSet or a fileSystem resourceSet.
                type: object
                properties:
                  resources:
                    type: array
                    default: []
                    items:
                      type: object
                      oneOf:
                        - required: [ configMap ]
                        - required: [ fileSystem ]
                      properties:
                        configMap:
                          description: The configMap resourceSet loads the Kubernetes manifests from an Kubernetes configMap.
                          type: object
                          properties:
                            name:
                              description: The name of the configMap
                              type: string
                            files:
                              description: (Optional) Specifies which files from the configMap should be loaded. If this field is not set, all files are loaded.
                              type: array
                              items:
                                type: string
                        fileSystem:
                          description: The fileSystem resourceSet loads the Kubernetes manifests from the filesystem.
                          type: object
                          properties:
                            path:
                              description: The path to the folder which contains the Kubernetes manifests files.
                              type: string
                            files:
                              description: (Optional) Specifies which files from the configMap should be loaded. If this field is not set, all files are loaded.
                              type: array
                              items:
                                type: string
                  beforeActions:
                    type: array
                    default: []
                    description: SUT before actions are executed before the SUT is started.
                    items:
                      type: object
                      properties:
                        selector:
                          type: object
                          description: The selector specifies which resource should be selected for the execution of the command.
                          properties:
                            pod:
                              type: object
                              description: Specifies the pod.
                              properties:
                                matchLabels:
                                  type: object
                                  description: The matchLabels of the desired pod.
                                  additionalProperties: true
                                  x-kubernetes-map-type: "granular"
                                  default: { }
                            container:
                              description: Specifies the container.
                              default: ""
                              type: string
                        exec:
                          type: object
                          description: Specifies command to be executed.
                          properties:
                            command:
                              type: array
                              description: The command to be executed as string array.
                              items:
                                type: string
                            timeoutSeconds:
                              description: Specifies the timeout (in seconds) for the specified command.
                              type: integer
                  afterActions:
                    type: array
                    default: []
                    items:
                      type: object
                      properties:
                        selector:
                          type: object
                          description: The selector specifies which resource should be selected for the execution of the command.
                          properties:
                            pod:
                              type: object
                              description: Specifies the pod.
                              properties:
                                matchLabels:
                                  type: object
                                  description: The matchLabels of the desired pod.
                                  additionalProperties: true
                                  x-kubernetes-map-type: "granular"
                                  default: { }
                            container:
                              description: Specifies the container.
                              default: ""
                              type: string
                        exec:
                          type: object
                          description: Specifies command to be executed.
                          properties:
                            command:
                              type: array
                              description: The command to be executed as string array.
                              items:
                                type: string
                            timeoutSeconds:
                              description: Specifies the timeout (in seconds) for the specified command.
                              type: integer
              loadGenerator:
                description: The loadGenResourceSets specifies all Kubernetes resources required to start the load generator. A resourceSet can be either a configMap resourceSet or a fileSystem resourceSet.
                type: object
                properties:
                  resources:
                    type: array
                    default: []
                    items:
                      type: object
                      oneOf:
                        - required: [ configMap ]
                        - required: [ fileSystem ]
                      properties:
                        configMap:
                          description: The configMap resourceSet loads the Kubernetes manifests from an Kubernetes configMap.
                          type: object
                          properties:
                            name:
                              description: The name of the configMap
                              type: string
                            files:
                              description: (Optional) Specifies which files from the configMap should be loaded. If this field is not set, all files are loaded.
                              type: array
                              items:
                                type: string
                        fileSystem:
                          description: The fileSystem resourceSet loads the Kubernetes manifests from the filesystem.
                          type: object
                          properties:
                            path:
                              description: The path to the folder which contains the Kubernetes manifests files.
                              type: string
                            files:
                              description: (Optional) Specifies which files from the configMap should be loaded. If this field is not set, all files are loaded.
                              type: array
                              items:
                                type: string
                  beforeActions:
                    type: array
                    default: [ ]
                    description: Load generator before actions are executed before the load generator is started.
                    items:
                      type: object
                      properties:
                        selector:
                          type: object
                          description: The selector specifies which resource should be selected for the execution of the command.
                          properties:
                            pod:
                              type: object
                              description: Specifies the pod.
                              properties:
                                matchLabels:
                                  type: object
                                  description: The matchLabels of the desired pod.
                                  additionalProperties: true
                                  x-kubernetes-map-type: "granular"
                                  default: { }
                            container:
                              description: Specifies the container.
                              default: ""
                              type: string
                        exec:
                          type: object
                          description: Specifies command to be executed.
                          properties:
                            command:
                              type: array
                              description: The command to be executed as string array.
                              items:
                                type: string
                            timeoutSeconds:
                              description: Specifies the timeout (in seconds) for the specified command.
                              type: integer
                  afterActions:
                    type: array
                    default: []
                    description: Load generator after actions are executed after the teardown of the load generator.
                    items:
                      type: object
                      properties:
                        selector:
                          type: object
                          description: The selector specifies which resource should be selected for the execution of the command.
                          properties:
                            pod:
                              type: object
                              description: Specifies the pod.
                              properties:
                                matchLabels:
                                  type: object
                                  description: The matchLabels of the desired pod.
                                  additionalProperties: true
                                  x-kubernetes-map-type: "granular"
                                  default: { }
                            container:
                              description: Specifies the container.
                              default: ""
                              type: string
                        exec:
                          type: object
                          description: Specifies command to be executed.
                          properties:
                            command:
                              type: array
                              description: The command to be executed as string array.
                              items:
                                type: string
                            timeoutSeconds:
                              description: Specifies the timeout (in seconds) for the specified command.
                              type: integer
              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.
                      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
          status:
            type: object
            properties:
              resourceSetsState:
                description: The status of a Benchmark indicates whether all resources are available to start the benchmark or not.
                type: string
    additionalPrinterColumns:
    - name: Age
      type: date
      jsonPath: .metadata.creationTimestamp
    - name: Status
      type: string
      description: The status of a Benchmark indicates whether all resources are available to start the benchmark or not.
      jsonPath: .status.resourceSetsState
    subresources:
      status: {}
  scope: Namespaced