apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: localvolumes.hwameistor.io
spec:
  group: hwameistor.io
  names:
    kind: LocalVolume
    listKind: LocalVolumeList
    plural: localvolumes
    shortNames:
    - lv
    singular: localvolume
  scope: Cluster
  versions:
  - additionalPrinterColumns:
    - description: Name of storage pool
      jsonPath: .spec.poolName
      name: pool
      type: string
    - description: Number of volume replica
      jsonPath: .spec.replicaNumber
      name: replicas
      type: integer
    - description: Required capacity of the volume
      jsonPath: .spec.requiredCapacityBytes
      name: capacity
      type: integer
    - description: Accessibility of volume
      jsonPath: .spec.accessibility.node
      name: accessibility
      type: string
    - description: State of the volume
      jsonPath: .status.state
      name: state
      type: string
    - description: Allocated resource ID for the volume
      jsonPath: .spec.config.resourceID
      name: resource
      type: integer
    - description: Name of the node where the volume is in-use
      jsonPath: .status.publishedNode
      name: published
      type: string
    - jsonPath: .metadata.creationTimestamp
      name: age
      type: date
    name: v1alpha1
    schema:
      openAPIV3Schema:
        description: LocalVolume is the Schema for the volumes API
        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 info: https://git.k8s.io/community/contributors/devel/sig-architecture/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/sig-architecture/api-conventions.md#types-kinds'
            type: string
          metadata:
            type: object
          spec:
            description: LocalVolumeSpec defines the desired state of LocalVolume
            properties:
              accessibility:
                description: Accessibility is the topology requirement of the volume.
                  It describes how to locate and distribute the volume replicas
                properties:
                  node:
                    description: One of the volume replica must be located at this
                      node
                    type: string
                  regions:
                    default:
                    - default
                    description: regions where the volume replicas should be distributed
                      across, it's Optional
                    items:
                      type: string
                    type: array
                  zones:
                    default:
                    - default
                    description: zones where the volume replicas should be distributed
                      across, it's Optional
                    items:
                      type: string
                    type: array
                type: object
              config:
                description: 'Config is the configration for the volume replicas It
                  will be managed by the controller, and watched by all the nodes
                  Important: node will manage volume replica according this config'
                properties:
                  convertible:
                    description: Convertible is to indicate if the non-HA volume can
                      be transitted to HA volume or not
                    type: boolean
                  initialized:
                    type: boolean
                  readyToInitialize:
                    type: boolean
                  replicas:
                    items:
                      description: VolumeReplica contains informations of replica
                        peer
                      properties:
                        hostname:
                          type: string
                        id:
                          type: integer
                        ip:
                          type: string
                        primary:
                          type: boolean
                      required:
                      - hostname
                      - id
                      - ip
                      - primary
                      type: object
                    type: array
                  requiredCapacityBytes:
                    format: int64
                    type: integer
                  resourceID:
                    description: ResourceID is for HA volume, set to '-1' for non-HA
                      volume
                    type: integer
                  version:
                    description: Version of config, start from 0, plus 1 every time
                      config update
                    type: integer
                  volumeName:
                    type: string
                required:
                - initialized
                - readyToInitialize
                - replicas
                - resourceID
                - version
                - volumeName
                type: object
              convertible:
                default: false
                description: Convertible is to indicate if the non-HA volume can be
                  transitted to HA volume or not
                type: boolean
              delete:
                default: false
                description: Delete is to indicate where the replica should be deleted
                  or not. It's different from the regular resource delete interface
                  in Kubernetes. The purpose is to protect it from any mistakes
                type: boolean
              poolName:
                description: PoolName is the name of the storage pool, e.g. LocalStorage_PoolHDD,
                  LocalStorage_PoolSSD, etc..
                type: string
              pvcName:
                description: PersistentVolumeClaimName is the name of the associated
                  PVC
                type: string
              pvcNamespace:
                description: PersistentVolumeClaimNamespace is the namespace of the
                  associated PVC
                type: string
              replicaNumber:
                description: 'replica number: 1 - non-HA, 2 - HA, 3 - migration (temp)'
                format: int64
                maximum: 3
                minimum: 1
                type: integer
              requiredCapacityBytes:
                format: int64
                minimum: 4194304
                type: integer
              volumegroup:
                description: VolumeGroup is the group name of the local volumes. It
                  is designed for the scheduling and allocating.
                type: string
            type: object
          status:
            description: LocalVolumeStatus defines the observed state of LocalVolume
            properties:
              allocatedCapacityBytes:
                description: AllocatedCapacityBytes is the real allocated capacity
                  in bytes of the volume replicas. In case of HA volume with multiple
                  replicas, the value is equal to the one of a replica's size
                format: int64
                type: integer
              publishedNode:
                description: PublishedNodeName is the node where the volume is published
                  and used by pod
                type: string
              replicas:
                description: Volume is a logical concept and composed by one or many
                  replicas which will be located at different node.
                items:
                  type: string
                type: array
              state:
                description: State is the phase of volume replica, e.g. Creating,
                  Ready, NotReady, ToBeDeleted, Deleted
                type: string
            type: object
        type: object
    served: true
    storage: true
    subresources:
      status: {}
