apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  name: tuneds.tuned.openshift.io
spec:
  # group name to use for REST API: /apis/<group>/<version>
  group: tuned.openshift.io
  names:
    # kind is normally the CamelCased singular type. Your resource manifests use this.
    kind: Tuned
    listKind: TunedList
    # plural name to be used in the URL: /apis/<group>/<version>/<plural>
    plural: tuneds
    # singular name to be used as an alias on the CLI and for display
    singular: tuned
  scope: Namespaced
  # list of versions supported by this CustomResourceDefinition
  versions:
  - name: v1
    # 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
  #preserveUnknownFields: false	# Do not use "false" in k8s 1.15, recursively nested "match" sections are dropped.
  validation:
    openAPIV3Schema:
      description: 'Tuned is a collection of rules that allows cluster-wide deployment of
        node-level sysctls and more flexibility to add custom tuning specified by user needs.
        These rules are translated and passed to all containerized tuned daemons running in
        the cluster in the format that the daemons understand. The responsibility for applying
        the node-level tuning then lies with the containerized tuned daemons. More info:
        https://github.com/openshift/cluster-node-tuning-operator'
      type: object
      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 info2:
            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:
          description: 'spec is the specification of the desired behavior of Tuned. More info:
            https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status'
          type: object
          required:
          - profile
          - recommend
          properties:
            profile:
              description: 'Tuned profiles.'
              type: array
              items:
                description: 'A tuned profile.'
                type: object
                required:
                - name
                - data
                properties:
                  name:
                    description: 'Name of the tuned profile to be used in the recommend section.'
                    type: string
                  data:
                    description: 'Specification of the tuned profile to be consumed by the tuned daemon.'
                    type: string
            recommend:
              description: 'Selection logic for all tuned profiles.'
              type: array
              items:
                description: 'Selection logic for a single tuned profile.'
                type: object
                required:
                - profile
                - priority
                properties:
                  profile:
                    description: 'Name of the tuned profile to recommend.'
                    type: string
                  priority:
                    description: 'Tuned profile priority. Highest priority is 0.'
                    type: integer
                    format: int64
                    minimum: 0
                  match:
                    description: 'Rules governing application of a tuned profile connected by logical OR operator.'
                    type: array
                    items:
                      description: 'Rules governing application of a tuned profile.'
                      type: object
                      required:
                      - label
                      properties:
                        label:
                          description: 'Node or Pod label name.'
                          type: string
                        value:
                          description: 'Node or Pod label value. If omitted, the presence of label name is enough to match.'
                          type: string
                        type:
                          description: 'Match type: [node/pod]. If omitted, "node" is assumed.'
                          type: string
                          enum: [ 'node', 'pod' ]
                        match:
                          description: 'Additional rules governing application of the tuned profile connected by logical AND operator.'
                          type: array
                          items:
                            # OpenAPI v3 validation schemas containing $ref are not permitted => cannot do recursive validation in 1.14
                            # https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/#validation
                            type: object
        status:
          description: 'Status is the current state of Tuned. This cannot be overriden.'
          type: object
