apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: mayastorvolumes.openebs.io
spec:
  group: openebs.io
  versions:
    - name: v1alpha1
      served: true
      storage: true
      subresources:
        # The status part is updated by the controller and spec part by the user
        # usually. Well, not in this case. The mayastor's control plane updates both
        # parts and user is allowed to update some of the properties in the spec
        # too. Though status part remains read-only for the user.
        status: {}
      schema:
        openAPIV3Schema:
          type: object
          properties:
            apiVersion:
              type: string
            kind:
              type: string
            metadata:
              type: object
            spec:
              description: Specification of the mayastor volume.
              type: object
              required:
                - replicaCount
                - requiredBytes
              properties:
                replicaCount:
                  description: The number of replicas used for the volume.
                  type: integer
                  minimum: 1
                preferredNodes:
                  description: A list of preferred cluster nodes for the volume.
                  type: array
                  items:
                    type: string
                requiredNodes:
                  description: Only cluster nodes from this list should be used for the volume.
                  type: array
                  items:
                    type: string
                requiredBytes:
                  description: The minimum size of the volume.
                  type: integer
                  minimum: 1
                limitBytes:
                  description: The maximum size of the volume (if zero then same as the requiredBytes).
                  type: integer
                  minimum: 0
                protocol:
                  description: Share protocol of the nexus
                  type: string
            status:
              description: Properties related to current state of the volume.
              type: object
              properties:
                size:
                  description: The size of the volume if it has been created
                  type: integer
                  format: int64
                state:
                  description: Overall state of the volume.
                  type: string
                reason:
                  description: Further explanation of the state if applicable.
                  type: string
                targetNodes:
                  description: k8s node(s) with storage targets for the volume.
                  type: array
                  items:
                    type: string
                nexus:
                  description: Frontend of the volume.
                  type: object
                  properties:
                    node:
                      description: Name of the k8s node with the nexus.
                      type: string
                    deviceUri:
                      description: URI of a block device for IO.
                      type: string
                    state:
                      description: State of the nexus.
                      type: string
                    children:
                      description: Child devices of the nexus (replicas).
                      type: array
                      items:
                        description: child device of the nexus (replica).
                        type: object
                        properties:
                          uri:
                            description: URI used by nexus to access the child.
                            type: string
                          state:
                            description: State of the child as seen by the nexus.
                            type: string
                replicas:
                  description: List of replicas
                  type: array
                  items:
                    type: object
                    properties:
                      node:
                        description: Name of the k8s node with the replica.
                        type: string
                      pool:
                        description: Name of the pool that replica was created on.
                        type: string
                      uri:
                        description: URI of the replica used by the nexus.
                        type: string
                      offline:
                        description: Is replica reachable by control plane.
                        type: boolean
      additionalPrinterColumns:
        - name: Targets
          type: string
          description: k8s node(s) with storage targets for the volume.
          jsonPath: .status.targetNodes
        - name: Size
          type: integer
          format: int64
          description: Size of the volume
          jsonPath: .status.size
        - name: State
          type: string
          description: State of the storage pool
          jsonPath: .status.state
        - name: Age
          type: date
          jsonPath: .metadata.creationTimestamp
  scope: Namespaced
  names:
    kind: MayastorVolume
    listKind: MayastorVolumeList
    plural: mayastorvolumes
    singular: mayastorvolume
    shortNames: ['msv']
